LoginSignup
9
6

More than 3 years have passed since last update.

VSCode で "Cannot find runtime 'node' on PATH. Is 'node' installed?" との戦い

Last updated at Posted at 2020-01-06

Cannot find runtime 'node' on PATH. Is 'node' installed?というダイアログが!

Node.js でサーバーサイド書く簡単なサンプルを真似して作ろうとしてデバッグ環境を整えてるときに発生
node -vってやってもちゃんと返却値あるし原因がわからない。。。
"一応" 解決したのでその方法を記載します。

環境

  • OS: macOS Catalina version 10.15.1
  • VSCode: 1.40.2
  • Node: v12.14.0 (installed by nodebrew)

TLDR

launch.json に以下の設定を追加

"runtimeExecutable": "/usr/local/var/nodebrew/current/bin/node" <- which node の結果をそのまま貼り付けた

レファレンス によると

runtimeExecutable - absolute path to the runtime executable to be used. Default is node. See section Launch configuration support for 'npm' and other tools.

runtimeExecutable: '実行ファイルの絶対パスを書く。デフォルトはnode。'
のような感じかな。。?

戦いの記録

launch.json はどうなってる?

program はちゃんと app.js となっていて問題ない感じ。。。

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "Launch Program",
            "skipFiles": [
                "<node_internals>/**"
            ],
            "program": "${workspaceFolder}/app.js"
        }
    ]
}

実行

でも実行すると "Cannot find runtime 'node' on PATH. Is 'node' installed?" が出る、、、なぜ、、、?泣
Is 'node' installed? とおっしゃいますがちゃんと node はインストールしてるよ???

調べる

いくつかサイトを見てみたけどなんかしっくりこない、、、
その中で runtimeExecutable という単語が出てきてパス指定してるような雰囲気が、、!
レファレンス見て真似してなんとかデバッグできるようになりました。

まとめ

この方法でデバッグできるようにはなったけどなぜデフォルトだと node がないと言われてしまうのか謎、、、
nodebrew でやってるから??
でも $PATH にはちゃんと追加してるしなー
ということで動いたけどしっくりこない感じ。。。
正しい方法知ってる方がいらっしゃったら教えて欲しい、、ぜひ、、っ

9
6
4

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
9
6