使用Laravel Mix - Vue编译时出错





我一直在使用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

你必须升级你的节点,所以试试这些命令:

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

检查节点版本:

sudo node -v

它必须显示类似v14的东西。*

您可能需要重新启动终端以查看更新后的节点版本。

然后输入npm run dev

最新更新