nvs icon indicating copy to clipboard operation
nvs copied to clipboard

npm doesn't work in Git Bash for a linked node.js version

Open Deilan opened this issue 4 years ago • 6 comments

Repro steps:

  1. Install nvs v1.6.0 via MSI installer for a current user.
  2. Setup for Git Bash as per Git Bash on Windows.
  3. Using Git Bash add node.js 8.17.0, use it and link it as a default (any other version also fails). image
  4. Relaunch Git Bash, check whether node and npm works: image

Expected result:

  1. node -v outputs v8.17.0
  2. npm -v outputs v6.13.4

Actual result:

  1. node -v outputs v8.17.0
  2. npm -v outputs:
module.js:550
    throw err;
    ^

Error: Cannot find module 'C:\Program Files\Git\Users\ovchinnikov\AppData\Local\nvs\default\node_modules\npm\bin\npm-cli.js'
    at Function.Module._resolveFilename (module.js:548:15)
    at Function.Module._load (module.js:475:25)
    at Function.Module.runMain (module.js:694:10)
    at startup (bootstrap_node.js:204:16)
    at bootstrap_node.js:625:3

Environment

Windows x64 20H2 nvs v1.6.0

~/.bashrc contents:

export NVS_HOME=$LOCALAPPDATA/nvs
. $NVS_HOME/nvs.sh

~/.bash_profile contents:

if [ -f ~/.bashrc ]; then . ~/.bashrc; fi

Deilan avatar Jan 06 '21 07:01 Deilan

The same use case works fine for Command Prompt and Powershell.

Deilan avatar Jan 06 '21 07:01 Deilan

do you @jasongin have any suggestion on this? I found that the main cause behind gitbash/mingw issues is that nvs detects windows platform first and does not anticipate any bash shell anymore. If my assumption is right, I'm happy to open a PR for this.

https://github.com/jasongin/nvs/blob/0b7279943e1b5a81db6721d71e986a1259907f61/lib/install.js#L20-L44

zsoltlengyelit avatar Feb 03 '21 10:02 zsoltlengyelit

There is a functional test that runs in the CI that is intended to validate operations within git bash on Windows, including npm: https://github.com/jasongin/nvs/blob/master/test/cli/gitBashTests.js

Do you know if that test is not validating enough or not validating correctly? Or is there something different about how that runs compared to your environment?

I don't have much time to work on this, and I don't normally use git bash day to day. So if you do have a solution, a PR would be welcome!

jasongin avatar Feb 03 '21 16:02 jasongin

@jasongin @Deilan could you please check my pr? GH does not allow me to add reviewers. Thanks for comments in advance

zsoltlengyelit avatar Apr 15 '21 07:04 zsoltlengyelit

Is there any update on this issue? We cannot use NVS because Link does not work for NPM on Git Bash.

milenvk avatar Feb 11 '22 19:02 milenvk

This has to be a joke

StEvUgnIn avatar May 25 '22 06:05 StEvUgnIn