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

[Help]Cannot run 'node' or 'npm' command after nvm installed #221

Closed
ghost opened this issue Nov 6, 2016 · 43 comments
Closed

[Help]Cannot run 'node' or 'npm' command after nvm installed #221

ghost opened this issue Nov 6, 2016 · 43 comments

Comments

@ghost
Copy link

ghost commented Nov 6, 2016

I'm trying to install nvm on my windows8.1(64bits). I do as the below orders:

  1. Download zip file.

  2. Unzip and install it.

  3. Configure the env path.

  4. Try to run 'nvm v' and it works well.
    image

  5. Try to install nodejs nvm install 4.2.4 64, after a while it tells me installation completed and suggests to run nvm use 4.2.4 to use it.
    image

  6. I run node -v to see if it really works. Unfortunately, I met some error msg.
    image
    It means 'This application cannot be run on your computer.'

It confused me. Did anyone meet the same error before? And How to solve it ??

@espoelstra
Copy link

espoelstra commented Nov 7, 2016

You will need to run this inside an "Administrator" or elevated command prompt. To change/create the symlinks nvm requires Administrator permissions.

You can probably run regular 'node' and 'npm' commands and some of the non-modifying 'nvm' commands in a non-Administrator prompt, but to make changes to the symlink it requires elevation.

@jaqen404
Copy link

jaqen404 commented Nov 8, 2016

I encountered the same problem

@ghost
Copy link
Author

ghost commented Nov 22, 2016

@summerinsect Do u fix it?

@andrewbhy
Copy link

andrewbhy commented Nov 22, 2016

I have the same problem. Currently using Windows 10 and have Windows Defender running.

  1. Windows Defender doesn't recognize any threats while running the nvm install.
  2. I am using administrator mode for the command prompt
  3. I do not see any error message during the node install :

nvm_problem_01

  1. nvm list gives me the following output :
    nvm_problem_02

  2. c:\program files\nodejs folder only contains node_modules folder which makes me think that the nvm installation wasn't completed properly.

Any suggestions?

--- Update ----

I have resolved the issue by doing the following :

  1. I've reinstalled nvm with different NVM_SYMLINK path
    ( changed from c:\program files\nodejs to c:\nodejs )

  2. Used PowerShell with admin rights

  3. Typed command [nvm on], which copied the node & npm to the NVM_SYMLINK folder ( this command didn't do anything with previous set ups, now it copies the files properly ).

My guess is that even though I was running the command prompt with admin right, it didn't have the write access to \program files\nodejs folder.

@ghost
Copy link
Author

ghost commented Nov 26, 2016

@andrewbhy Cool, it works! Thank you so much!

@ghost ghost closed this as completed Nov 26, 2016
@ghost ghost reopened this Nov 26, 2016
@ghost
Copy link
Author

ghost commented Nov 26, 2016

Unfortunately, the issue haven't been fixed yet. :( Now, I could run node command, but couldn't run npm command:
image

image

Is there anything I missed??


Update:
Fixed! The npm installation haven't completed yet which caused this issue(Cannot find module ... npm-cli.js).

@ghost ghost closed this as completed Nov 26, 2016
@bmcminn
Copy link

bmcminn commented Dec 7, 2016

Steps provided above didn't work for me... I have NVM_HOME and NVM_SYMLINK configured in my local and system path as variables, and included them in my system PATH, however, I run nvm use *.*.* and no matter which version I switch to, NVM creates the symlink, but doesn't persist the Node instance I wish to use.

Far as I can tell, everything is where it needs to be, but NVM isn't persisting which Node version I've set using nvm use.

Extra info: This is a fresh Win7 64 bit instance and I never installed Node on it before trying to get NVM going.

@dragon788
Copy link

I don't think you want to have the NVM_HOME and NVM_SYMLINK in both places. What do you have in your settings.txt file?

@bmcminn
Copy link

bmcminn commented Dec 9, 2016

@dragon788 I figured out the issue, but it wasn't related to the env path variables. Mind you, NVMs installer setup both variables in both places, so that was not a decision made on my part.

The fix for my issue is detailed in #230

@fresheneesz
Copy link

fresheneesz commented Dec 27, 2016

@coreybutler I have the same problem. After installation, I can run it in admin mode, but not in normal user mode. I seem to remember last time I used this (months ago at this point), that I could use nvm from whereever, but if an installation needed to happen, a prompt would come up. That's a much better experience - you shouldn't have to launch an admin cmd prompt. I think we should reopen this issue.

@coreybutler
Copy link
Owner

If you're downloading the manual installer, this is the experience you can likely expect because nothing is setup for you. This is why I made the installer. It prepares everything for you, including permissions. Keep in mind it is not enough to run this as an administrator on some versions of Windows. Later versions of Windows requires elevated admin privileges, though in most scenarios it should prompt you when you install a new version or make a switch.

If you install NVM4W anywhere within C:\Program Files\, you must use an account with admin privileges. This is a restriction of Windows itself, which considers this a protected directory.

If you're having problems with persisting a version of Node, make sure your account has write permissions on the NVM for Windows user data directory. This is required to write the settings.txt file.

If you're on Windows 7, please read about Windows 7 support.

@fresheneesz
Copy link

@coreybutler I'm not sure what you mean by "manual installer" vs "the installer". I used https://github.com/coreybutler/nvm-windows/releases/download/1.1.1/nvm-setup.zip . My account has admin privileges, but its annoying to have to manually start a cmd prompt with admin privileges in order to access it.

Are you saying if I install nvm somewhere other than program files it'll work without elevated privileges?

@coreybutler
Copy link
Owner

@fresheneesz - sorry for being as clear as mud :) By "manual" installer, I meant the "nvm-noinstall.zip". You're using "the installer", i.e. the GUI that walks you through the setup process.

Depending on your version of Windows, installing elsewhere only requires admin privileges, not elevated admin privileges. It still needs admin privileges whenever it switches to a new version though (symlinking).

@fresheneesz - I just ran a fresh install in Windows 10 and it prompts when switching versions, so I'm not sure why you're having to open a new prompt with admin privileges. Do you have something like cmder/cygwin/git shell installed? Sometimes these shells cause problems like this.

@fresheneesz
Copy link

I seem to have gotten it to work, but I think my computer might be always opening up a cmd prompt with admin mode now? I'm not sure, it suddenly switched to always being green on black, which I thought was admin mode. IDK but it works now so yay!

@dragon788
Copy link

Green on Black is the "cmd" prompt. White on Blue is the "PowerShell" prompt. You can usually tell the Administrator permissions in the title bar, it will say "Administrator" up there and sometimes will start in C:\Windows\system32 when it first opens.

@PostImpatica
Copy link

PostImpatica commented Sep 6, 2017

Your going to think I'm crazy but I couldn't get npm to work because the files weren't being created for npm deep in the directory tree within c:\Program Files\nodejs\node_mudules\npm No matter how I ran the cmd.exe wether as administrator or not. For giggles I ran the powershell as admin and it had no problem creating the files on Windows Server 2012 R2. What powershell does differently than cmd.exe I have no idea. One annoying thing though, it's slow.

@PostImpatica
Copy link

PostImpatica commented Sep 6, 2017

..Er, well, all kinds of craziness. Had issues with Node v8.4.0 even though I could set/use 6.11.3 with no problem. I ended up uninstalling/removing v8.4.0 and this time when I reinstalled v8.4.0 I left off the "v" and it worked.

@dragon788
Copy link

@helzgate cmd.exe is limited to the 256 character path depth I believe while the PowerShell "shell" doesn't seem to suffer from that limitation. Weird that the v vs no v makes a difference, I'd hope they would use mostly the same logic and just strip the preceding character but I haven't checked out that code in depth.

@githubbob42
Copy link

I had the same problem (I could only run nvm and node as the admin after default install). However, if you choose different install directories, other than the defaults (I used c:/nodejs for Node and c:/bin/nvm for NVM) it works perfectly. I no longer need to be admin to run node or nvm. No special setup or configuration, just select different install locations and that was it.

@dragon788
Copy link

When I put together the Chocolatey package I believe I had it install to C:\ProgramData because that is accessible by all users but only writable by administrators, but that means as long as you run your nvm install and npm install -g type commands from an administrator prompt everything else should work without the space issue I think.

@SanjanaTailor
Copy link

using nvm windows how to install cordova ?

Repository owner deleted a comment from psiddharth709 Sep 25, 2017
@psiddharth709
Copy link

npm install -g cordova

@SanjanaTailor
Copy link

SanjanaTailor commented Oct 6, 2017

Facing this problem after installing nvm
module.js:471
throw err;
^

Error: Cannot find module 'C:\Windows\System32\node_modules\cordova\bin\cordova'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:383:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:496:3

E:\Cordova projects\CordovaApp>nvm ls

  • 6.11.4 (Currently using 64-bit executable)
    Facing this problem can not run cordova for 2 months. Help me.
    Also while installing cordova facing this problem;
    E:\Cordova projects\CordovaApp>npm install -g cordova
    npm WARN deprecated node-uuid@1.4.8: Use uuid module instead
    E:\Cordova projects\CordovaTemplate1\cordova -> E:\Cordova projects\CordovaTemplate1\node_modules\cordova\bin\cordova
  • cordova@7.0.1

@coreybutler
Copy link
Owner

@SanjanaTailor - did you have a prior version of Node installed before using nvm4w? See https://github.com/coreybutler/nvm-windows#installation--upgrades

@ChuckkNorris
Copy link

If anyone else encountered an issue where the node or npm commands were not found after installing and using a version, I managed to resolve this by turning nvm on and off:

nvm off

nvm on

example

@noodlesegg
Copy link

Excellent @ChuckkNorris

@dvnrsn
Copy link

dvnrsn commented Mar 22, 2018

I tried @ChuckkNorris trick without success. What appears to have worked for me was after nvm install latest including in Path:

C:\Users\<user>\AppData\Roaming\nvm\v9.8.0

I also see a nodejs in C:\Program Files...wonder if that is attached to nvm

@csempesz
Copy link

This is a nightmare. I mean to make this work. I tried all the above: install nvm into something else then Program Files, used PowelShell (Admin) to launch the install, switched on/off nvm, basically none of them worked.
Strange thing is that when I tried to install into something else then Program Files (like c:\nodejs), nvm install deleted the target directory and nothing got installed.
I'm using Windows 10. At this poitn I'm not recommending using this product to manage multiple node version.

@b-dur
Copy link

b-dur commented May 11, 2018

Hi @csempesz. Could you try uninstall NVM and then install this pre-release and see if it solves your problem?
https://github.com/b-dur/nvm-windows/releases/tag/1.1.7

@emekaokoli
Copy link

emekaokoli commented Jul 4, 2018

I fixed mine like this...

  1. Reinstalled nvm as admin (even though I am using admin account)
  2. nvm on
  3. Installed a single node version as admin with Powershell.
    I am using windows 10.

@gdutleung
Copy link

gdutleung commented Jul 24, 2018

Just use powershell rather than cmd and try again.

@martyglaubitz
Copy link

@csempesz dont install it via the installer - use chocolatey. This in conjunction with turning nvm on and off, solved it for me

@sachinmjadhav
Copy link

Installed in a different folder then turned nvm on and off, npm -v works but node -v gives an error "The system cannot find the path specified"

@adamorlowskipoland
Copy link

3. nvm on

Fixed all bugs for me.

@mynormh
Copy link

mynormh commented Dec 24, 2018

Still getting this problem with 1.1.7 on windows 10. node -v works fine but npm -v gives me:
image

Also, my nod_modules folder is empty

@papb
Copy link

papb commented Jan 28, 2019

I finally fixed this in Windows 7 by:

  • Uninstalling nvm
  • Installing it on nondefault folders (C:\nvm and C:\nodejs)
  • Altering manually the %PATH% to use these paths directly instead of %NVM_HOME% and %NVM_SYMLINK%
  • nvm install 10.15.0
  • nvm off
  • nvm on
  • nvm use 10.15.0

@ilog2000
Copy link

Just run into this issue with nvm v1.1.7 on Windows 10. The solution in my case was to completely delete 'C:\Program Files\nodejs' directory (it existed after NodeJS uninstall). After that nvm use 11.8.0 started working normally.

@mynormh
Copy link

mynormh commented Jan 29, 2019

Thanks! I’ll try to do this and see if it works.

@alhadathavale
Copy link

@ChuckkNorris That worked! Thx!

@salvimateus
Copy link

@ilog2000 PERFECT! Thank you

@presiden
Copy link

presiden commented Nov 4, 2022

If anyone else encountered an issue where the node or npm commands were not found after installing and using a version, I managed to resolve this by turning nvm on and off:

nvm off

nvm on

example

Great! it works. Just run as admin

@LeedsCode
Copy link

tldr; If none of the methods before work, the specific version of node you're trying to use may have installed incorrectly. Try uninstalling it and reinstalling using nvm uninstall {version} and nvm install {version}

All of the previous methods did not work for me. What went wrong for me is one of the versions of Node I installed using nvm install did not install correctly. I actually switched to a VPN while it was downloading. It showed an error, but it still made it seem like it worked as I could use it. However it gave me the same error. I switched to a different version of node and that one was working, but it wouldn't work with this latest version I had installed. After I uninstalled that version and reinstalled it, it's working again!

@phaddmin
Copy link

I finally fixed this in Windows 7 by:

  • Uninstalling nvm
  • Installing it on nondefault folders (C:\nvm and C:\nodejs)
  • Altering manually the %PATH% to use these paths directly instead of %NVM_HOME% and %NVM_SYMLINK%
  • nvm install 10.15.0
  • nvm off
  • nvm on
  • nvm use 10.15.0

Using powershell as admin every time was not an option for me... With NVM v1.1.11, the above worked for me but only needed to do the first 2 steps; uninstall nvm, install again on non-default folders directly under C: drive. I didnt need to update the NVM_HOME and NVM_SYMLINK variables.

This issue was closed.
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