LoginSignup
15
11

More than 1 year has passed since last update.

$ npm run watch しようとしたら Sorry, there's a problem with nodist. Couldn't resolve node version ~~~と出たときの対処法

Last updated at Posted at 2020-07-08

課題

$ npm run watch

しようとしたら
Sorry, there's a problem with nodist. Couldn't resolve node version spec %s: %s 4.5.0 Couldn't find any matching version
と怒られた。

なんでだろうと調べたりいろいろ試したりしましたが小1時間ほどハマり心優しい同僚に助けてもらったので覚書しておきます。
池田さんありがと。

対処法

1. nodeのバージョンを確認する

node -v
v0.0.0

2. .node-version(node-dev-env/.node-version)を開いて記載されているバージョンを確認する

私の場合「v11.13.0」と記載されていました。
このバージョンとnode-v したときのバージョンを合わせてやります。

3. 今適用されているnode.jsのバージョンを確認

$ nodist
  (x64)
> 4.5.0  (C:\xampp\htdocs\hogehoge.jp\node-dev-env\.node-version: v4.5.0)
  10.15.1  (global: 10.15.1)
  11.0.0
  11.13.0

つまり現在のnode.jsのバージョンが4.5.0になってしまっている。(私の場合11.13.0も一応存在はしました)

4. v11.13.0がなければインストール

$ nodist + v11.13.0

5. v11.13.0がインストール済になったので切り替える

$ nodist v11.13.0
v11.13.0
v11.13.0 (global)

6. node.jsのバージョンが切り替わったか確認しましょ

$ node -v
v11.13.0

これで切り替え完了!

7. 頼む、動いてくれ!

$ npm run watch

8. それでも動かなかったとき

魔法の呪文
(使用中の node にあったバージョンの npm をインストールしてくれます)

$ nodist npm match

9. それでもまだ動かなかったとき

おまじない
(npm config スクリプトの設定でパスを先頭に追加)

$ npm config set scripts-prepend-node-path true

からの

npm config list

; userconfig C:\Users\whatthehell\.npmrc
scripts-prepend-node-path = true

が追加されていることを確認します。
そして

npm run watch

終わり

ここまでの手順でわたしは動きました。

参考:

nodist 環境下で npm script 使用時にエラー – blog
https://www.namu-ws.com/blog/dev/nodist-npm-script-error

npm がどうしてもエラーになってしまったら - Qiita
https://qiita.com/tana08/items/d50212a1919308cc1480

Laravel-Mixコンパイル時のcode ELIFECYCLEエラーに対応する - Qiita
https://qiita.com/ishizukih/items/9673e709832dacaa5155

nodistでnode.jsのバージョン管理をする | IT王子の技術ブログ
https://www.it-ouji.com/2019/10/26/nodist%E3%81%A7node-js%E3%81%AE%E3%83%90%E3%83%BC%E3%82%B8%E3%83%A7%E3%83%B3%E7%AE%A1%E7%90%86%E3%82%92%E3%81%99%E3%82%8B/

15
11
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
15
11