【发布时间】:2019-05-04 15:08:57
【问题描述】:
我安装了 Laravel 并运行 npm run watch 命令,它返回:
ERROR in ./node_modules/destroy/index.js
Module not found: Error: Can't resolve 'fs' in 'C:\xampp\htdocs\checknpm\node_modules\destroy'
ERROR in ./node_modules/express/lib/request.js
Module not found: Error: Can't resolve 'net' in 'C:\xampp\htdocs\checknpm\node_modules\express\lib'
ERROR in ./node_modules/engine.io/lib/server.js
Module not found: Error: Can't resolve 'uws' in 'C:\xampp\htdocs\checknpm\node_modules\engine.io\lib'
然后我在laravel中设置了一些配置webpack.mix.js:
mix.webpackConfig({
target: "node",
});
然后它重新调整:
WARNING in ./node_modules/socket.io/lib/index.js
113:11-32 Critical dependency: the request of a dependency is an expression
WARNING in ./node_modules/node-gyp-build/index.js
13:9-32 Critical dependency: the request of a dependency is an expression
WARNING in ./node_modules/node-gyp-build/index.js
20:15-54 Critical dependency: the request of a dependency is an expression
WARNING in ./node_modules/express/lib/view.js
81:13-25 Critical dependency: the request of a dependency is an expression
ERROR in ./node_modules/engine.io/lib/server.js
Module not found: Error: Can't resolve 'uws' in 'C:\xampp\htdocs\checknpm\node_modules\engine.io\lib'
最后我补充说:
mix.webpackConfig({
target: "node",
externals: {
uws: "uws",
ws: "ws",
},
});
当我运行 npm run watch 时它返回:
WARNING in ./node_modules/socket.io/lib/index.js
113:11-32 Critical dependency: the request of a dependency is an expression
@ ./node_modules/socket.io/lib/index.js
@ ./resources/js/bootstrap.js
@ ./resources/js/app.js
@ multi ./resources/js/app.js ./resources/sass/app.scss
WARNING in ./node_modules/express/lib/view.js
81:13-25 Critical dependency: the request of a dependency is an expression
@ ./node_modules/express/lib/view.js
@ ./node_modules/express/lib/application.js
@ ./node_modules/express/lib/express.js
@ ./node_modules/express/index.js
@ ./resources/js/bootstrap.js
@ ./resources/js/app.js
@ multi ./resources/js/app.js ./resources/sass/app.scss
我尝试了不同的方法,但没有奏效!我想与 Laravel 建立套接字关系,但是它向我发送了这些错误,甚至不允许我运行套接字。我该如何解决?
【问题讨论】:
-
第一次运行
npm install -
我已经运行了它,但我又按照你说的再次运行它但没有结果:(
-
我可以看到这些重新警告,这里没有错误
-
在socket编程过程中不会出问题吗?
标签: node.js laravel npm webpack laravel-mix