赞
踩
(1)nodejs中使用mqtt服务,运行命令node mqttserver.js,发现报错 : 缺少mosca包
(2)那就装一个, npm install mosca --save
(--save
表示安装的包将写入package.json
里面的dependencies
)
(3)装完之后再一次node mqttserver.js
,结果发现还是报错:
PS D:\nodejs\nodejs_practice_lzl> node mqttserver.js D:\nodejs\nodejs_practice_lzl\node_modules\jsonschema\lib\validator.js:110 throw new SchemaError('Expected `schema` to be an object or boolean'); ^ SchemaError: Expected `schema` to be an object or boolean at Validator.validate (D:\nodejs\nodejs_practice_lzl\node_modules\jsonschema\lib\validator.js:110:11) at Object.validate (D:\nodejs\nodejs_practice_lzl\node_modules\mosca\lib\options.js:264:26) at new Server (D:\nodejs\nodejs_practice_lzl\node_modules\mosca\lib\server.js:104:34) at Object.<anonymous> (D:\nodejs\nodejs_practice_lzl\mqttserver.js:3:18) at Module._compile (node:internal/modules/cjs/loader:1105:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10) at Module.load (node:internal/modules/cjs/loader:981:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12) at node:internal/main/run_main_module:17:47 { schema: undefined }
(1)在错误提示中找到错误地址:
D:\nodejs\nodejs_practice_lzl\node_modules\jsonschema\lib\validator.js
(2)打开文件后,注释掉这三行:
(3)再次运行,node mqttserver.js
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。