【问题标题】:Error in Laravel-mixLaravel 混合中的错误
【发布时间】:2018-09-15 05:05:21
【问题描述】:

我在 VPS 上安装带有 npm 和节点的 Laravel-mix

操作系统是 Ubuntu 16.4

Laravel 版本为:5.6

npm 版本是:3.5.2

节点版本为:v4.2.6

运行后sudo npm run production

显示此错误:

production /var/www/html
cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --
no-progress --hide-modules --config=node_modules/laravel-
mix/setup/webpack.config.js
/var/www/html/node_modules/laravel-mix/setup/webpack.config.js:6
let mix = require('../src/index');
^^^
SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:374:25)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at requireConfig (/var/www/html/node_modules/webpack/bin/convert-argv.js:97:18)
at /var/www/html/node_modules/webpack/bin/convert-argv.js:104:17
at Array.forEach (native)

npm ERR! Linux 4.4.0-87-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "run" "production"
npm ERR! node v4.2.6
npm ERR! npm  v3.5.2
npm ERR! code ELIFECYCLE
npm ERR! @ production: `cross-env NODE_ENV=production 
node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @ production script 'cross-env 
NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js'.
npm ERR! Make sure you have the latest version of node.js and npm 
installed.
npm ERR! If you do, this is most likely a problem with the  package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     cross-env NODE_ENV=production         node_modules/webpack/bin/webpack.js --no-progress --hide-modules --    config=node_modules/laravel-mix/setup/webpack.config.js
npm ERR! You can get information on how to open an issue for this     project with:
npm ERR!     npm bugs 
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls 
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /var/www/html/npm-debug.log

如何发出这个问题?

【问题讨论】:

标签: laravel laravel-5 webpack laravel-mix


【解决方案1】:

我只是按照这些步骤操作,一切正常。尝试完全重置:

rm -rf node_modules
rm package-lock.json yarn.lock
npm cache clear --force
npm install

【讨论】:

    【解决方案2】:

    将您的 npmnode 版本更新到最新版本。

    只需运行npm i -g npm

    而且你不需要sudo 来运行npm 脚本。只需使用npm run production

    【讨论】:

      【解决方案3】:

      可能您使用的是新旧版本的 node,它与您的某些软件包不兼容(请参阅运行 npm install 时的所有警告)。尝试更改节点版本。

      nvm use 14
      

      【讨论】:

        【解决方案4】:

        某些情况下节点版本出问题,试试 n 14 将节点版本更改为 14(如果您已安装)

        【讨论】:

          猜你喜欢
          • 2017-08-17
          • 1970-01-01
          • 2021-09-14
          • 2019-02-11
          • 2020-11-30
          • 2019-06-20
          • 2017-08-12
          • 1970-01-01
          • 2015-08-09
          相关资源
          最近更新 更多