目的
-
$ npm run dev
を実行したところエラーが出たので解決策をメモ的に残す。
エラーまでの経緯
-
下記コマンドを実行した。
$ npm run dev
エラー
-
下記のエラーが出力された。
[16:08:46]MacBook-Pro~/workspase/work/todo_app/todos$ npm run dev > @ dev /Users/okawashun/workspase/work/todo_app/todos > npm run development > @ development /Users/okawashun/workspase/work/todo_app/todos > mix Error: You are using an unsupported version of Node. Please update to at least Node v12.14 at assertSupportedNodeVersion (/Users/okawashun/workspase/work/todo_app/todos/node_modules/laravel-mix/src/Engine.js:6:15) at executeScript (/Users/okawashun/workspase/work/todo_app/todos/node_modules/laravel-mix/bin/cli.js:61:5) at Command.program.command.description.option.action.cmd (/Users/okawashun/workspase/work/todo_app/todos/node_modules/laravel-mix/bin/cli.js:47:13) at Command.listener [as _actionHandler] (/Users/okawashun/workspase/work/todo_app/todos/node_modules/commander/index.js:426:31) at Command._parseCommand (/Users/okawashun/workspase/work/todo_app/todos/node_modules/commander/index.js:1002:14) at Command._dispatchSubcommand (/Users/okawashun/workspase/work/todo_app/todos/node_modules/commander/index.js:953:18) at Command._parseCommand (/Users/okawashun/workspase/work/todo_app/todos/node_modules/commander/index.js:979:12) at Command.parse (/Users/okawashun/workspase/work/todo_app/todos/node_modules/commander/index.js:801:10) at Command.parseAsync (/Users/okawashun/workspase/work/todo_app/todos/node_modules/commander/index.js:828:10) at run (/Users/okawashun/workspase/work/todo_app/todos/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! /Users/okawashun/.npm/_logs/2021-03-10T07_08_54_349Z-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! /Users/okawashun/.npm/_logs/2021-03-10T07_08_54_372Z-debug.log
解決までの経緯
-
「Please update to at least Node v12.14」と出力されている。現在のNode.jsのバージョンをまず確認してみる。下記コマンドを実行してNode.jsのバージョンを確認した。
$ node --version
-
下記のように出力された。確かにかなり古い。
# use a specific version number node use v8.9.4
-
下記コマンドを実行してNode.jsの12.14をインストールする。
$ nodebrew install v12.14
-
インストール完了後に下記コマンドを実行してNode.jsのバージョンを切り替える。
$ nodebrew use v12.14.1
-
下記コマンドを実行してNode.jsのバージョンを確認する。
$ node --version
-
Node.jsのバージョンがv12.14.1になったことが確認できた。
-
再度
$ npm run dev
を実行したところ正常に実行された。