3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

npm ERR! spawn ENOENT

Posted at

状況

Vueプロジェクトで、 npm run serve してブラウザで確認しようとしたら Error: spawn ENOENT が発生しました。

調べたところ、このエラーは 

 ①コマンドが存在しない 
 ②作業ディレクトリが存在しない 
 ③ウィンドウズ特有のバグ 

のどれかであることがほとんど、との情報ありましたが、macなので③は無し。

内容

sh: run-p: command not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! project-name serve: `run-p dev api:doc mock:watch`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the project-name serve 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/UserName/.npm/_logs/2021-05-01T09_53_04_840Z-debug.log

run-p(npm-run-all --parallel のショートカット) というコマンドは知らない。 と行頭にあります。 package.json 内のココの部分です。

.json
"scripts":     
    "serve": "run-p dev api:doc mock:watch"
}

ちなみに /Users/UserName/.npm/_logs/2021-05-01T09_53_04_840Z-debug.log のログにもっと情報がある、と上記エラー文でありますが、あまり手がかりになるものはなかったです。

対処

下記コマンドで npm-run-all のパッケージをインストールする必要があるようです。

$ npm install --save-dev npm-run-all

または、インストールしたパッケージを全て削除し、インストールし直すことで確実に解決します(今回この方法をとりました)

$ rm -rf node_modules
$ npm install
3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?