node start mqtt error: SchemaError: Expected `schema` to be an object or boolean

created at 03-19-2022 views: 33


Use the mqtt service in node, run the command node mqttserver.js, and find an error: the mosca package is missing:

Error: Cannot find module 'mosca'

Then install one, npm install mosca After installing node mqttserver.js again, I found that it still reported an error

SchemaError: Expected `schema` to be an object or boolean


Copy the path underlined in red in the image below

copy the path

Open a random folder, paste the path into the navigation bar, press Enter, you will enter the lib and see the validator.js file

Open this file with a text editor, slide to the position around the 108 line, comment out the three lines of code in the red circle in the figure below, and save

edit the file

Run it again, node mqttserver.js

mqtt runs successfully.

created at:03-19-2022
edited at: 03-19-2022: