jasongin / nvs

Node Version Switcher - A cross-platform tool for switching between versions and forks of Node.js
Other
2.74k stars 210 forks source link

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

Open tpburch opened 5 years ago

tpburch commented 5 years ago

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:

Actual result:

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 commented 5 years ago

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
jviolas commented 3 years ago

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