Я установил 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, однако он посылает мне эти ошибки и даже не позволяет запускать сокет.как я могу это исправить?