【问题标题】:Error while compiling with Laravel Mix - Vue使用 Laravel Mix 编译时出错 - Vue
【发布时间】:2021-05-11 02:55:33
【问题描述】:



我一直在 Vue Js 旁边使用 Laravel 8,它们一起工作得很好。我尝试再次使用 Laravel 和 Vue Js 启动一个项目,但一周后它给了我一个错误。我使用了以下命令:
Laravel v8.26.1 (PHP v7.4.3)

composer create-project --prefer-dist laravel/laravel <project_name>

它工作正常,之后:

npm install

也很好用

但是当我尝试运行npm run dev时出现错误

npm run dev
> @ dev <project_path>
> npm run development


> @ development <project_path>
> mix

Error: You are using an unspported version of Node. Please update to at least Node v12.14
    at assertSupportedNodeVersion (<project_path>/node_modules/laravel-mix/src/Engine.js:6:15)
    at executeScript (<project_path>/node_modules/laravel-mix/bin/cli.js:58:5)
    at Command.program.command.description.option.action.cmd (<project_path>/node_modules/laravel-mix/bin/cli.js:44:13)
    at Command.listener [as _actionHandler] (<project_path>/node_modules/commander/index.js:426:31)
    at Command._parseCommand (<project_path>/node_modules/commander/index.js:1002:14)
    at Command._dispatchSubcommand (<project_path>/node_modules/commander/index.js:953:18)
    at Command._parseCommand (<project_path>/node_modules/commander/index.js:979:12)
    at Command.parse <project_path>/node_modules/commander/index.js:801:10)
    at Command.parseAsync (<project_path>/node_modules/commander/index.js:828:10)
    at run (<project_path>/node_modules/laravel-mix/bin/cli.js:47:19)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ development: `mix`
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/user/.npm/_logs/2021-02-06T07_19_07_707Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ dev: `npm run development`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @ dev 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/user/.npm/_logs/2021-02-06T07_19_07_767Z-debug.log

package.json

{
"private": true,
"scripts": {
    "dev": "npm run development",
    "development": "mix",
    "watch": "mix watch",
    "watch-poll": "mix watch -- --watch-options-poll=1000",
    "hot": "mix watch --hot",
    "prod": "npm run production",
    "production": "mix --production"
},
"devDependencies": {
    "axios": "^0.21",
    "bootstrap": "^4.0.0",
    "cross-env": "^5.1",
    "jquery": "^3.2",
    "laravel-mix": "^6.0.6",
    "lodash": "^4.17.19",
    "popper.js": "^1.12",
    "resolve-url-loader": "^2.3.1",
    "sass": "^1.20.1",
    "sass-loader": "^8.0.0",
    "vue": "^2.5.17",
    "vue-router": "^3.4.9",
    "vue-template-compiler": "^2.6.10"
},
"dependencies": []
}

我没有做任何特别的事情或配置任何东西!
提前谢谢;D

【问题讨论】:

标签: php laravel vue.js laravel-8 laravel-mix


【解决方案1】:

您必须升级您的节点,因此请尝试以下命令:

sudo npm cache clean -f
sudo npm install -g n
sudo n stable

检查节点版本:

sudo node -v

它必须显示类似 v14.* 的内容

您可能需要重新启动终端才能看到更新的节点版本。

然后做npm run dev

【讨论】:

  • 嘿,它成功了。谢谢你的帮助;D。我一直在寻找很多来解决这个错误,但没有找到。加上安装过程比以前的版本快得多。惊人的 [波斯语 = Chakeretim dadash]
  • 这行得通!谢谢你,让它成为正确的。我花了很多时间在这上面。
  • @Dasunwijesundara 很高兴您的问题得到了解决。
猜你喜欢
  • 2021-05-27
  • 2018-08-13
  • 2021-06-16
  • 1970-01-01
  • 2019-08-01
  • 2019-02-27
  • 1970-01-01
  • 1970-01-01
  • 2020-08-04
相关资源
最近更新 更多