Skip to content

Instantly share code, notes, and snippets.

@stormwild
Last active June 11, 2022 03:10
Show Gist options
  • Save stormwild/8ff4328c6f8b92ba4d4b4a0908c324f6 to your computer and use it in GitHub Desktop.
Save stormwild/8ff4328c6f8b92ba4d4b4a0908c324f6 to your computer and use it in GitHub Desktop.

Revisions

  1. stormwild revised this gist May 19, 2019. 1 changed file with 25 additions and 0 deletions.
    25 changes: 25 additions & 0 deletions vscode-terminal-nvm.md
    Original file line number Diff line number Diff line change
    @@ -42,6 +42,31 @@ Launching Visual Studio Code from the terminal using `code` and then opening a t
    But it seems we have to call `nvm use v10.15.3` to use node specified by `nvm`.
    When launching Terminal within Visual Studio Code run the following example:
    ```
    nvm use v10.15.3
    ```
    This will ensure that the node and npm version being run in that particular terminal session will use the node specified by nvm. You will have to do this for every terminal you launch.
    > nvm uses a shell function (instead of an environment variable) to configure the path to the node.js.
    >
    > This is not supported in VS Code on macOS.
    >
    > The workaround is to use the runtimeVersion attribute:
    >
    > ```
    > {
    > "type": "node",
    > "request": "launch",
    > "name": "Launch Program",
    > "program": "${workspaceFolder}/test.js",
    > "runtimeVersion": "4.6"
    > }
    > ```
    ...research in progress
    ## References
  2. stormwild revised this gist May 19, 2019. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions vscode-terminal-nvm.md
    Original file line number Diff line number Diff line change
    @@ -38,6 +38,12 @@ In Visual Studio Code settings.json:
    > bash # "-" is NOT the first character. This is NOT a login shell.
    > ```
    Launching Visual Studio Code from the terminal using `code` and then opening a terminal allows nvm to load.
    But it seems we have to call `nvm use v10.15.3` to use node specified by `nvm`.
    ...research in progress
    ## References
    - [Install & Update script](https://github.com/nvm-sh/nvm#install--update-script)
  3. stormwild created this gist May 19, 2019.
    51 changes: 51 additions & 0 deletions vscode-terminal-nvm.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,51 @@
    # Visual Studio Code NVM Node Issue


    ## NVM

    Given that `nvm` is installed on Mac OS X High Sierra or Mojave using the install script

    `~/.bash_profile`
    ```
    export NVM_DIR="$HOME/.nvm"
    [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
    ```

    ## Visual Studio Code

    On Mac Visual Studio Code can be launched from the launcher or dock or from the terminal by running `code <path>`

    In Visual Studio Code settings.json:

    > ### Shell arguments
    >
    > You can pass arguments to the shell when it is launched.
    >
    > For example, to enable running bash as a login shell (which runs .bash_profile), pass in the -l argument (with double quotes):
    `~/Library/Application Support/Code/User/settings.json`
    ```json
    {
    "terminal.integrated.shellArgs.osx": ["-l"]
    }
    ```

    > ```
    > prompt> echo $0
    > -bash # "-" is the first character. Therefore, this is a login shell.
    >
    > prompt> echo $0
    > bash # "-" is NOT the first character. This is NOT a login shell.
    > ```
    ## References
    - [Install & Update script](https://github.com/nvm-sh/nvm#install--update-script)
    - [nvm is not compatible with the npm config “prefix” option:](https://stackoverflow.com/questions/34718528/nvm-is-not-compatible-with-the-npm-config-prefix-option)
    - [Integrated terminal does not see Node from NVM #48576](https://github.com/Microsoft/vscode/issues/48576)
    - [NVM is not compatible with the npm config "prefix" option warning (OS X) #1245](https://github.com/nvm-sh/nvm/issues/1245)
    - [What does this command do? “exec bash -l”](https://stackoverflow.com/questions/26747455/what-does-this-command-do-exec-bash-l)
    - [Configuration](https://code.visualstudio.com/docs/editor/integrated-terminal#_configuration)
    - [Shell arguments](https://code.visualstudio.com/docs/editor/integrated-terminal#_shell-arguments)
    - [Difference between Login Shell and Non-Login Shell?](https://unix.stackexchange.com/questions/38175/difference-between-login-shell-and-non-login-shell/46856#46856)