nvs icon indicating copy to clipboard operation
nvs copied to clipboard

npm commands don't work using git bash on windows after "link"

Open tpburch opened this issue 6 years ago • 2 comments

Steps to Reproduce:

  1. Follow the Git Bash on Windows instructions for installation
  2. Install a node version (I installed v10.15.1 through the initial setup by calling nvs)
  3. Setup the version as default with "link" (I used nvs link 10.15.1)
  4. In a new Bash shell, run npm -v

Expected result:

  • You should see the installed npm version

Actual result:

  • got the below error:
$ npm -v
internal/modules/cjs/loader.js:583
    throw err;
    ^

Error: Cannot find module 'C:\Program Files\Git\Users\{username}\AppData\Local\nvs\default\node_modules\npm\bin\npm-cli.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
    at Function.Module._load (internal/modules/cjs/loader.js:507:25)
    at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)

I found when I inspected PATH in this shell, the path to the nvs/default folder was a windows-style path, not a POSIX path.

tpburch avatar Feb 14 '19 19:02 tpburch

I was able to get this working locally by changing the entry in my .bashrc to:

export NVS_HOME=`cygpath "$LOCALAPPDATA/nvs"`
. $NVS_HOME/nvs.sh

tpburch avatar Feb 14 '19 19:02 tpburch

Got the same issue and the change with cygpath also fixed it for me.

jviolas avatar Mar 04 '21 15:03 jviolas