Vscode-code-runner: Wrong node version referenced

Created on 21 Dec 2016  路  2Comments  路  Source: formulahendry/vscode-code-runner

Hi, great extensions, thanks.

I use nvm to manage a multi-version node environment.

The problem is like below:

  1. Start VSC, (node version = 4.7)
  2. in the integrated terminal, which has the following settings in the user settings
//to enable running bash as a login shell (which runs `.bash_profile`)
"terminal.integrated.shellArgs.osx": [
        "-l"
    ],
  1. Run the command, "nvm use 6", now the node version changes to 6
  2. Executing console.log(process.version), the output is v4.7.0
  3. In the integrated terminal, executing the file by node test.js, the output is v6.9.2
  4. nvm will add the following lines to the .bash_profile:
export NVM_DIR="/Users/albertgao/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"  # This loads nvm
  1. but seems I don't know how to add it to the "code-runner.executorMap": {}

It would be super nice if the code-runner could use the interpreter which comes from the integrated terminal or at least we can configure it :) Thanks.

question

Most helpful comment

There would be two options:

  • Set "code-runner.runInTerminal": true in the user settings, so that the js file will run in integrated terminal
  • Customize the script in executorMap what you like. I am not familiar with nvm, but per you description, you may add setting like below to use node version 6:
"code-runner.executorMap": {
    "javascript": "nvm use 6 && node"
}

All 2 comments

There would be two options:

  • Set "code-runner.runInTerminal": true in the user settings, so that the js file will run in integrated terminal
  • Customize the script in executorMap what you like. I am not familiar with nvm, but per you description, you may add setting like below to use node version 6:
"code-runner.executorMap": {
    "javascript": "nvm use 6 && node"
}

the first one works like a charm while the second not, thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

manikantag picture manikantag  路  4Comments

0x7FFFFFFFFFFFFFFF picture 0x7FFFFFFFFFFFFFFF  路  3Comments

seiferthan picture seiferthan  路  4Comments

mjaniec2013 picture mjaniec2013  路  5Comments

ElektroStudios picture ElektroStudios  路  4Comments