Nvm-windows: [Help]Cannot run 'node' or 'npm' command after nvm installed

Created on 6 Nov 2016  路  40Comments  路  Source: coreybutler/nvm-windows

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
  1. 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
  2. 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 ??

Most helpful comment

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

All 40 comments

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.

I encountered the same problem

@summerinsect Do u fix it?

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.

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

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).

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.

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?

@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

@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.

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.

@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?

@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.

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!

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.

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.

..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.

@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.

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.

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.

using nvm windows how to install cordova ?

npm install -g cordova

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

Error: Cannot find module 'C:\Windows\System32node_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 [email protected]: Use uuid module instead
    E:\Cordova projects\CordovaTemplate1\cordova -> E:\Cordova projects\CordovaTemplate1node_modules\cordova\bin\cordova

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

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

Excellent @ChuckkNorris

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

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.

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

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.

Just use powershell rather than cmd and try again.

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

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"

3. nvm on

Fixed all bugs for me.

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

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

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

Thanks! I鈥檒l try to do this and see if it works.

@ChuckkNorris That worked! Thx!

@ilog2000 PERFECT! Thank you

Was this page helpful?
0 / 5 - 0 ratings