没有不值得去解决的问题,也没有不值得去学习的技术!

On Windows 10, “npm run dev” Fails: Update to Node v12.14 or Later

In Laravel 8.6.3, after installing Laravel Breeze and running npm run dev, an error occurred: You are using an unsupported version of Node. Please update to at least Node v12.14.

1. In Laravel 8.6.3, after installing Laravel Breeze and running npm run dev, an error occurred: You are using an unsupported version of Node. Please update to at least Node v12.14. See Figure 1.

In Laravel 8.6.3, after installing Laravel Breeze and running npm run dev, an error occurred: You are using an unsupported version of Node. Please update to at least Node v12.14.
Figure 1
Plaintext

PS E:\wwwroot\laravel-8-5> php artisan breeze:install
Breeze scaffolding installed successfully.
Please execute the "npm install && npm run dev" command to build your assets.
PS E:\wwwroot\laravel-8-5> npm install
npm WARN notice [SECURITY] lodash has the following vulnerability: 1 high. Go here for more details: https://www.npmjs.com/advisories?search=lodash&version=4.17.21 - Run `npm i npm@latest -g` to upgrade your npm version, and then `npm audit` to get more info.
npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.3.2 (node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN postcss-load-config@3.1.0 requires a peer of ts-node@>=9.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN webpack-notifier@1.14.1 requires a peer of @types/webpack@^4.41.31 but none is installed. You must install peer dependencies yourself.
npm WARN ws@8.2.3 requires a peer of bufferutil@^4.0.1 but none is installed. You must install peer dependencies yourself.
npm WARN ws@8.2.3 requires a peer of utf-8-validate@^5.0.2 but none is installed. You must install peer dependencies yourself.

added 812 packages in 126.222s
PS E:\wwwroot\laravel-8-5> npm run dev

> @ dev E:\wwwroot\laravel-8-5
> npm run development


> @ development E:\wwwroot\laravel-8-5
> mix

Error: You are using an unsupported version of Node. Please update to at least Node v12.14
    at assertSupportedNodeVersion (E:\wwwroot\laravel-8-5\node_modules\laravel-mix\src\Engine.js:6:15)
    at executeScript (E:\wwwroot\laravel-8-5\node_modules\laravel-mix\bin\cli.js:61:5)
    at Command.program.command.description.option.action (E:\wwwroot\laravel-8-5\node_modules\laravel-mix\bin\cli.js:47:13)
    at Command.listener [as _actionHandler] (E:\wwwroot\laravel-8-5\node_modules\commander\index.js:922:31)
    at Command._parseCommand (E:\wwwroot\laravel-8-5\node_modules\commander\index.js:1503:14)
    at Command._dispatchSubcommand (E:\wwwroot\laravel-8-5\node_modules\commander\index.js:1443:18)
    at Command._parseCommand (E:\wwwroot\laravel-8-5\node_modules\commander\index.js:1469:12)
    at Command.parse (E:\wwwroot\laravel-8-5\node_modules\commander\index.js:1292:10)
    at Command.parseAsync (E:\wwwroot\laravel-8-5\node_modules\commander\index.js:1318:10)
    at run (E:\wwwroot\laravel-8-5\node_modules\laravel-mix\bin\cli.js:50: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!     C:\Users\Administrator\AppData\Roaming\npm-cache\_logs\2021-10-21T02_45_05_986Z-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!     C:\Users\Administrator\AppData\Roaming\npm-cache\_logs\2021-10-21T02_45_06_047Z-debug.log
PS E:\wwwroot\laravel-8-5>


2. Checked the Node.js version: v8.10.0. The required version is at least Node v12.14. See Figure 2.

Checked the Node.js version: v8.10.0. The required version is at least Node v12.14.
Figure 2
Plaintext

PS E:\wwwroot\laravel-8-5> node -v
v8.10.0

3. Referenced URL: https://www.jianshu.com/p/0f3fdf6c0d5f to reinstall the latest stable version. Downloaded 14.18.1 LTS. The installation path was kept the same as the old version: C:/Program Files/nodejs. See Figure 3.

Referenced URL: https://www.jianshu.com/p/0f3fdf6c0d5f to reinstall the latest stable version. Downloaded 14.18.1 LTS. The installation path was kept the same as the old version: C:/Program Files/nodejs.
Figure 3

4. Checked the Node.js version again: v14.18.1. See Figure 4.

Checked the Node.js version again: v14.18.1.
Figure 4
Plaintext

PS E:\wwwroot\laravel-8-5> node -v
v8.10.0
PS E:\wwwroot\laravel-8-5> npm -v
5.5.1
PS E:\wwwroot\laravel-8-5> where node
PS E:\wwwroot\laravel-8-5> node -v
v14.18.1
PS E:\wwwroot\laravel-8-5> npm -v
5.5.1

5. npm WARN npm npm does not support Node.js v14.18.1. Referenced URL: https://stackoverflow.com/questions/63196042/npm-does-not-support-node-js-v12-18-3 . Navigated to the directory: C:\Users\Administrator\AppData\Roaming\. Deleted the npm and npm-cache folders. See Figure 5.

npm WARN npm npm does not support Node.js v14.18.1. Referenced URL: https://stackoverflow.com/questions/63196042/npm-does-not-support-node-js-v12-18-3 . Navigated to the directory: C:\Users\Administrator\AppData\Roaming\. Deleted the npm and npm-cache folders.
Figure 5

6. Checked the npm version: 6.14.15, and updated npm again. Executed the command: npm install -g npm. Upgraded to version: 8.1.0. See Figure 6.

Checked the npm version: 6.14.15, and updated npm again. Executed the command: npm install -g npm. Upgraded to version: 8.1.0.
Figure 6
Plaintext

PS E:\wwwroot\laravel-8-5> npm -v
6.14.15
PS E:\wwwroot\laravel-8-5> npm install -g npm
C:\Users\Administrator\AppData\Roaming\npm\npm -> C:\Users\Administrator\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js
C:\Users\Administrator\AppData\Roaming\npm\npx -> C:\Users\Administrator\AppData\Roaming\npm\node_modules\npm\bin\npx-cli.js
+ npm@8.1.0
added 220 packages from 96 contributors in 25.764s
PS E:\wwwroot\laravel-8-5> npm -v
8.1.0
PS E:\wwwroot\laravel-8-5>

7. Repeated step 1, the installation succeeded and the error no longer occurred. This was as expected. See Figure 7.

Repeated step 1, the installation succeeded and the error no longer occurred. This was as expected.
Figure 7
Plaintext
PS E:\wwwroot\laravel-8-5> npm -v
8.1.0
PS E:\wwwroot\laravel-8-5> php artisan breeze:install
Breeze scaffolding installed successfully.
Please execute the "npm install && npm run dev" command to build your assets.
PS E:\wwwroot\laravel-8-5> composer require laravel/breeze --dev
Using version ^1.4 for laravel/breeze
./composer.json has been updated
Running composer update laravel/breeze
Loading composer repositories with package information
Updating dependencies
Nothing to modify in lock file
Installing dependencies from lock file (including require-dev)
Nothing to install, update or remove
Package sebastian/resource-operations is abandoned, you should avoid using it. No replacement was suggested.
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
Discovered Package: facade/ignition
Discovered Package: fruitcake/laravel-cors
Discovered Package: laravel/breeze
Discovered Package: laravel/sail
Discovered Package: laravel/sanctum
Discovered Package: laravel/tinker
Discovered Package: nesbot/carbon
Discovered Package: nunomaduro/collision
Package manifest generated successfully.
78 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
> @php artisan vendor:publish --tag=laravel-assets --ansi
No publishable resources for tag [laravel-assets].
Publishing complete.
PS E:\wwwroot\laravel-8-5> npm run devnpm install
^C终止批处理操作吗(Y/N)? Y
PS E:\wwwroot\laravel-8-5> npm install
npm WARN old lockfile
npm WARN old lockfile The package-lock.json file was created with an old version of npm,
npm WARN old lockfile so supplemental metadata must be fetched from the registry.
npm WARN old lockfile
npm WARN old lockfile This is a one-time fix-up, please be patient...
npm WARN old lockfile
npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.

changed 48 packages, and audited 813 packages in 1m

88 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
PS E:\wwwroot\laravel-8-5> npm run dev

> dev
> npm run development


> development
> mix



* Mix █████████████████████████ emitting (95%)
 emit




* Mix █████████████████████████ done (99%) plugins
 WebpackBar:done



√ Mix
  Compiled successfully in 10.53s



   Laravel Mix v6.0.34


✔ Compiled Successfully in 10214ms
┌───────────────────────────────────────────────────────────────────────────────────────────────────────────┬──────────┐
│                                                                                                      File │ Size     │
├───────────────────────────────────────────────────────────────────────────────────────────────────────────┼──────────┤
│                                                                                                /js/app.js │ 682 KiB  │
│                                                                                               css/app.css │ 3.83 MiB │
└───────────────────────────────────────────────────────────────────────────────────────────────────────────┴──────────┘

* Mix █████████████████████████ cache (99%)
 begin idle

webpack compiled successfully
PS E:\wwwroot\laravel-8-5> php artisan migrate
Nothing to migrate.
PS E:\wwwroot\laravel-8-5>

关于作者 · 持续学习与技术实践

我是一名拥有 15 年以上开发经验的技术从业者,自 2013 年起持续运营个人技术博客,记录工作与个人项目中遇到的真实问题,以及解决问题过程中的探索、实践和思考。

除了技术写作,我也在持续开发和维护自己的独立项目,探索新技术和新工具在实际场景中的应用。我始终相信,没有不值得去解决的问题,也没有不值得去学习的技术。

如果这篇文章对你有所帮助,欢迎浏览博客中的其他文章,也欢迎交流技术经验与想法。

关于我  ·  GitHub  ·  邮件联系