webpack Laravel 7需要什么版本的节点和npm?

ruarlubt  于 2023-01-21  发布在  Webpack
关注(0)|答案(2)|浏览(191)

在哪里可以看到节点和npm Laravel 7需要什么版本?
文档中没有任何内容:www.example.comhttps://laravel.com/docs/7.x/mix#installation
我安装了这些版本,但在运行"npm run development"时出现错误

npm -v
6.14.5

node -v
v6.17.0

已经阅读了旧版本的npm和节点,可能导致该原因。还阅读了cross-env的位置已更改,但不确定这意味着什么或在哪里更改:/
错误:

ec2-user:~/environment (master) $ npm run development

> @ development /home/ec2-user/environment
> cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

/home/ec2-user/environment/node_modules/chokidar/index.js:151
  async remove(item) {
        ^^^^^^

SyntaxError: Unexpected identifier
    at NativeCompileCache._moduleCompile (/home/ec2-user/environment/node_modules/v8-compile-cache/v8-compile-cache.js:240:18)
    at Module._compile (/home/ec2-user/environment/node_modules/v8-compile-cache/v8-compile-cache.js:186:36)
    at Object.Module._extensions..js (module.js:586:10)
    at Module.load (module.js:494:32)
    at tryModuleLoad (module.js:453:12)
    at Function.Module._load (module.js:445:3)
    at Module.require (module.js:504:17)
    at require (/home/ec2-user/environment/node_modules/v8-compile-cache/v8-compile-cache.js:161:20)
    at Object.<anonymous> (/home/ec2-user/environment/node_modules/sass/sass.dart.js:98:17)
    at Module._compile (/home/ec2-user/environment/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
    at Object.Module._extensions..js (module.js:586:10)
    at Module.load (module.js:494:32)
    at tryModuleLoad (module.js:453:12)
    at Function.Module._load (module.js:445:3)
    at Module.require (module.js:504:17)
    at require (/home/ec2-user/environment/node_modules/v8-compile-cache/v8-compile-cache.js:161:20)
    at implementation (/home/ec2-user/environment/node_modules/laravel-mix/src/components/Sass.js:55:27)
    at implementation (/home/ec2-user/environment/node_modules/laravel-mix/src/components/Preprocessor.js:130:61)
    at global.tap (/home/ec2-user/environment/node_modules/laravel-mix/src/helpers.js:10:5)
    at Sass.loaderOptions (/home/ec2-user/environment/node_modules/laravel-mix/src/components/Preprocessor.js:128:9)
    at extractPlugin (/home/ec2-user/environment/node_modules/laravel-mix/src/components/Preprocessor.js:87:39)
    at global.tap (/home/ec2-user/environment/node_modules/laravel-mix/src/helpers.js:10:5)
    at details.forEach (/home/ec2-user/environment/node_modules/laravel-mix/src/components/Preprocessor.js:27:13)
    at Array.forEach (native)
    at Sass.webpackRules (/home/ec2-user/environment/node_modules/laravel-mix/src/components/Preprocessor.js:22:22)
    at ComponentFactory.applyRules (/home/ec2-user/environment/node_modules/laravel-mix/src/components/ComponentFactory.js:155:23)
    at Mix.listen.rules (/home/ec2-user/environment/node_modules/laravel-mix/src/components/ComponentFactory.js:66:48)
    at events.(anonymous function).forEach.handler (/home/ec2-user/environment/node_modules/laravel-mix/src/Dispatcher.js:34:47)
    at Array.forEach (native)
    at Dispatcher.fire (/home/ec2-user/environment/node_modules/laravel-mix/src/Dispatcher.js:34:28)
    at Mix.dispatch (/home/ec2-user/environment/node_modules/laravel-mix/src/Mix.js:118:25)
    at WebpackConfig.buildRules (/home/ec2-user/environment/node_modules/laravel-mix/src/builder/WebpackConfig.js:90:13)
    at WebpackConfig.build (/home/ec2-user/environment/node_modules/laravel-mix/src/builder/WebpackConfig.js:23:14)
    at Object.<anonymous> (/home/ec2-user/environment/node_modules/laravel-mix/setup/webpack.config.js:29:38)
    at Module._compile (/home/ec2-user/environment/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
    at Object.Module._extensions..js (module.js:586:10)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ development: `cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @ development script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/ec2-user/.npm/_logs/2020-05-27T15_52_27_039Z-debug.log

尝试删除node_modules文件夹,然后运行"npm安装",但仍然得到错误。认为我已经运行最新版本的npm和节点。

dly7yett

dly7yett1#

好像我修好了。
这就是我所做的

npm cache clean --force

rm -rf node_modules package-lock.json

npm install

然后我得到了另一个错误:

ERROR in ./resources/sass/app.scss
Module build failed (from ./node_modules/css-loader/index.js):
ModuleBuildError: Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
ValidationError: Invalid options object. Sass Loader has been initialized using an options object that does not match the API schema.

这起了作用:

npm uninstall --save-dev sass-loader
npm install --save-dev sass-loader@7.1.0

现在可以运行“npm run development”,没有任何问题。

tmb3ates

tmb3ates2#

对于Laravel版本7.30节点js版本14.8为我工作.

npm install --save-dev

相关问题