我正在使用node-ssdp来检测连接到网络的物联网设备。服务器代码和客户端代码都可以很好地与示例节点项目一起工作。我的客户端应用程序是在angular-electron与webpack作为模块编译器。我在angular项目中安装了node-ssdp,
npm install node-ssdp --save
node-ssdp
安装成功。但是webpack失败了,出现以下错误。
ERROR in ./~/node-ssdp/test/lib/server.js
Module not found: Error: Can't resolve 'chai' in 'J:\fyp\desktop-client\node_modules\node-ssdp\test\lib'
@ ./~/node-ssdp/test/lib/server.js 3:13-28
@ ./~/node-ssdp ^.*server$
@ ./~/node-ssdp/index.js
@ ./src/app/providers/pd.service.ts
@ ./src/app/app.module.ts
@ ./src/main.ts
@ multi ./src/main.ts
ERROR in ./~/node-ssdp/test/lib/client.js
Module not found: Error: Can't resolve 'chai' in 'J:\fyp\desktop-client\node_modules\node-ssdp\test\lib'
@ ./~/node-ssdp/test/lib/client.js 4:13-28
@ ./~/node-ssdp ^.*client$
@ ./~/node-ssdp/index.js
@ ./src/app/providers/pd.service.ts
@ ./src/app/app.module.ts
@ ./src/main.ts
@ multi ./src/main.ts
ERROR in ./~/node-ssdp/test/helper.js
Module not found: Error: Can't resolve 'sinon' in 'J:\fyp\desktop-client\node_modules\node-ssdp\test'
@ ./~/node-ssdp/test/helper.js 1:12-28
@ ./~/node-ssdp/test/lib/server.js
@ ./~/node-ssdp ^.*server$
@ ./~/node-ssdp/index.js
@ ./src/app/providers/pd.service.ts
@ ./src/app/app.module.ts
@ ./src/main.ts
@ multi ./src/main.ts
ERROR in ./~/node-ssdp/test/helper.js
Module not found: Error: Can't resolve 'dgram' in 'J:\fyp\desktop-client\node_modules\node-ssdp\test'
@ ./~/node-ssdp/test/helper.js 3:12-28
@ ./~/node-ssdp/test/lib/server.js
@ ./~/node-ssdp ^.*server$
@ ./~/node-ssdp/index.js
@ ./src/app/providers/pd.service.ts
@ ./src/app/app.module.ts
@ ./src/main.ts
@ multi ./src/main.ts
我尝试手动安装上述缺失的chai, sinon, dgram
依赖项。chai
和sinon
错误被消除,但dgram
没有被消除。
我试了几次,浪费了几个小时。但我没有成功。有人能提出解决方案吗?
1条答案
按热度按时间7dl7o3gd1#
如果有人还在看这个,dgram被npm弃用,但被node采用。下面是dgram https://github.com/nodejs/node/blob/v20.5.1/lib/dgram.js的源代码。