使用 Laravel Mix 编译时出错 - Vue

Error while compiling with 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