Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The global npm directory is not put in the environment variable #391

Closed
1 of 23 tasks
waiholiu opened this issue Sep 11, 2018 · 9 comments
Closed
1 of 23 tasks

The global npm directory is not put in the environment variable #391

waiholiu opened this issue Sep 11, 2018 · 9 comments

Comments

@waiholiu
Copy link

waiholiu commented Sep 11, 2018

If this is a question about how to use NVM4W, please use stackoverflow instead.

If this is an issue regarding antivirus, make sure you search the existing issues first.

My Environment

  • Windows 7 or below (not truly supported due to EOL - see wiki for details)

  • Windows 8

  • Windows 8.1

  • Windows 10

  • Windows 10 IoT Core

  • Windows Server 2012

  • Windows Server 2012 R2

  • Windows Server 2016

  • My Windows installation is non-English.

I'm using NVM4W version:

  • [ x] 1.1.7
  • 1.1.6
  • 1.1.5
  • 1.1.4
  • 1.1.3
  • 1.1.2
  • 1.1.1
  • Older
  • OTHER (Please Specify)

I have already...

  • [x ] read the README to be aware of npm gotchas & antivirus issues.
  • [x ] reviewed the wiki to make sure my issue hasn't already been resolved.
  • [x ] verified I'm using an account with administrative privileges.
  • [x ] searched the issues (open and closed) to make sure this isn't a duplicate.
  • [x ] made sure this isn't a question about how to use NVM for Windows, since gitter is used for questions and comments.

My issue is related to (check only those which apply):

  • settings.txt
  • proxy support (Have you tried version 1.1.0+?)
  • 32 or 64 bit support (Have you tried version 1.1.3+?)
  • Character escaping (Have you tried version 1.1.6+?)
  • A standard shell environment (terminal/powershell)
  • A non-standard shell environment (Cmder, Hyper, Cygwin, git)

Expected Behavior

After I install nvm-windows, the C:\Users\admin\AppData\Roaming\npm that contains all my global commands should be added into PATH variable but this is not.

Actual Behavior

This is not - I have to manually go and add this directory to PATH variable

Steps to reproduce the problem:

Install nvm-windows
run npm install -g @angular/cli
close powershell window and re-open
run "ng new newProject"
It's going to say it "ng is not recognised command"
Go into environment variables, and add "C:\Users\admin\AppData\Roaming\npm" to PATH
Open another powershell window, and run "ng new newProject", it'll now work

@waiholiu
Copy link
Author

Actually maybe this is me misunderstanding how nvm-windows is supposed to work.

Can someone clarify, is nvm-windows supposed to put my global npm packages (eg. yarn, ng) into c:\users\admin\appdata\roaming\nvm?

It looks to me on my computer, the global packages are put in c:\users\admin\appdata\roaming\npm - only the node versions are put into c:\users\admin\appdata\roaming\nvm.

This is why the global commands do not work until I add c:\users\admin\appdata\roaming\npm into SYSTEM PATH.

@zoltanbedi
Copy link

Can someone clarify, is nvm-windows supposed to put my global npm packages (eg. yarn, ng) into c:\users\admin\appdata\roaming\nvm?

No it is not. That is the right behavior you are experiencing. Also nvm adds the c:\users\admin\appdata\roaming\npm to the PATH if it didn't you couldn't access npm.

@waiholiu
Copy link
Author

waiholiu commented Sep 12, 2018

Can someone clarify, is nvm-windows supposed to put my global npm packages (eg. yarn, ng) into c:\users\admin\appdata\roaming\nvm?

No it is not. That is the right behavior you are experiencing. Also nvm adds the c:\users\admin\appdata\roaming\npm to the PATH if it didn't you couldn't access npm.

Ok well it didn't add the c:\users\admin\appdata\roaming\npm directory to PATH for me. I had to manually add this afterwards.

It added NVM_HOME which linked to c:\users\admin\appdata\roaming\nvm and
NVM_SYMLINK which linked to c:\program files\nodejs

i could access npm because c:\program files\nodejs was pointing to my current version of node (eg. C:\Users\admin\AppData\Roaming\nvm\v10.10.0)

@westerdaled
Copy link

westerdaled commented Sep 12, 2018

I was getting this issue but realised this hadn't run this sucessfully
nvm install 8.12.0

Downloading node.js version 8.12.0 (64-bit)...
Complete
Downloading npm version 6.4.1... Download -failed. Rolling Back.

I think this explains the path not set. Anyway installed nvm 1.17 and successfully run the above - it adds these env vars which get appended to the path env var

NVM_HOME=C:\Users\danie\AppData\Roaming\nvm
NVM_SYMLINK=C:\Program Files\nodejs

npm is seen by the path and I stop getting the error mentioned in this thread
λ npm version
{ npm: '6.4.1',
.....

@westerdaled
Copy link

westerdaled commented Sep 13, 2018

I thought I would repeat the above on the laptop supplied by my client

  1. installed the last verison of NVM4W installer (1.17.4)

  2. set the proxy url

nvm proxy myclientproxy.com:xxxx

λ nvm install 8.12.0
Downloading node.js version 8.12.0 (64-bit)...
Complete
Downloading npm version 6.4.1... Download failed. Rolling Back.
Rollback failed. remove C:\Users\Daniel\AppData\Roaming\nvm\temp\npm-v6.4.1.zip: The process cannot access the file because it is being used by another process.
Could not download npm for node v8.12.0.
Please visit https://github.com/npm/cli/releases/tag/v6.4.1 to download npm.
It should be extracted to C:\Users\Daniel\AppData\Roaming\nvm\v8.12.0

Any advice on how resolve this or perform a manual install.

@ismailkattakath
Copy link

I had Nodist installed prior to nvm-windows. It left a .npmrc file under home directory (%userprofile%). I had to remove it and try nvm use command again to get everything right.

@earthbound19
Copy link

earthbound19 commented May 6, 2020

I don't know that my path had anything incorrect or missing, but re @ismailkattakath's solution, I also had extra .npmrc files laying around (in two places), and deleting them and attemting an npm install buzzphraze -g command worked and installed the package in the right place. Before this it was maddeningly creating a c\blar\mcblar\ folder structure in my drive root (in Windows).

Edit: on windows 7. For which the extras installs fails (and I got chocolatey installed through manual wrangling) because it is coded for powershell 1 but chocolately now requires TLS2 and powershell 5 to install. I wonder if the extras installs failures created .npmrc files in the wrong places.

@phaniva
Copy link

phaniva commented Sep 9, 2021

It appears nvm places commands in C:\Program Files (x86)\Nodist\bin. Adding that to path solved the issue for me. May be nvm installer can add that dir to the path

@AMDphreak
Copy link

@coreybutler This problem is still unfixed. I experienced this on nvm 1.1.9 on Windows 11, after using nvm to install Nodejs 18.7.0. It was not previously installed. The nvm list command returned empty until I installed Node with nvm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants