29

I have been trying to resolve this issue for the whole day.

When I run node -v or npm install in cmd prompt, it works absolutely fine. But when I run the same commands in Powershell, it gives the following error:s

PS C:\Users\Anubhav.Trivedi> node -v
The term 'node' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelli
ng of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:5
+ node <<<<  -v
    + CategoryInfo          : ObjectNotFound: (node:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

I tried uninstalling node js and reinstalling it. Added node js path C:\Program Files (x86)\nodejs\ to enviroment variables (system variables). Restarting computer. But nothing seems to work. Kindly let me know, what am I missing here.

Anubhav Trivedi
  • 1,130
  • 1
  • 12
  • 19
  • 4
    Check that the folder really is in your path. This will return a value if it is: `$env:path -split ';' | Select-String nodejs` Did you remember to restart the PowerShell console when you updated the Path environment variable? – dan-gph May 19 '15 at 07:05
  • Please put an answer and flag the question as answered. – JPBlanc May 19 '15 at 12:51

15 Answers15

46

These issues cannot be installed from the Package Manager console, so I had to browse lot of things to fix the issues and finally I got the solution.

Maybe we followed these scenarios

  • Missing Node.js software

  • Wrongly updated Windows environment path

  • Installed in the wrong path

  • Old version of Node.js software

You can download the latest Node.js software here.

Update Path

After installation, automatically create nodejs folder in this path “C:\Program Files (x86)” or “C:\Program Files “.

Open Control Panel -> User Accounts -> Change my environmental variable and verify the path Variable value “C:\Program Files (x86)\nodejs” or “C:\Program Files\nodejs “.

new => user = path => value = C:\Program Files (x86)\nodejs and after apply that.

and close Editor and restart it. it will work correctly.

note :- enter your path instead of copy of this path.

Daniel B
  • 3,109
  • 2
  • 33
  • 42
Neel Patel
  • 2,028
  • 18
  • 17
28

As dan-gph mentioned check the Path in environment variable using script $env:path -split ';' | Select-String nodejs and once you update the Path in environment variable, make sure to restart powershell and also restart explorer.exe. This would resolve the issue.

If you still face issues, check which nodejs you have installed (32bit or 64bit). Install 32 bit only as powershell or cmd are 32bit programs

Anubhav Trivedi
  • 1,130
  • 1
  • 12
  • 19
  • Hi! Would it be too much to ask about what it does exactly. It solved my issue here. Thanks! – onit Oct 21 '20 at 01:50
  • it didn't working though I have had created an environment variable I just clicked the 'Kill Terminal' in the powershell tab with your 'restart powershell' explanation and voila even after years! – gurkan Nov 05 '21 at 19:50
11

Model for VSCode editor

C:\Program Files\nodejs
C:\Program Files\nodejs\node_modules\npm\bin
  1. Search PATH environment variable.
  2. Add the above paths into the Environment variables (both user variable path and system variable path).
  3. Restart VSCode.
  4. Open a new terminal in VSCode
  5. run node --version output should equal v16.13.0
Julio Nobre
  • 4,196
  • 3
  • 46
  • 49
  • 1
    This worked for me. In case you're confused, the first path is for the user variable and the second path is for the system variable. – Dan Jul 08 '22 at 17:40
  • Just a follow-up... While node was working fine, npm was not. However, it's already been answered here: https://stackoverflow.com/questions/24721903/npm-npm-cli-js-not-found-when-running-npm#answer-24741740 – Dan Jul 08 '22 at 17:54
2

If you installed NodeJs recently after opening the IDE like Visual Studio Code or any other IDE that includes the terminal you are trying. then try this.

  1. Restart the IDE, If you installed NodeJs recently after opening the IDE like Visual Studio Code or any other IDE that includes the terminal you are trying.
  2. Restart the CommandLine if you installed NodeJs after you opened the CommandLine.

I hope it will be fixed most of the time by following these simple steps.

Happy Coding!

Ganesa Vijayakumar
  • 2,422
  • 5
  • 28
  • 41
0

open control panel then--

   user accounts
         |
   user accounts
         |
  change my environment variables
         |
        new 
         |
  (In variable name use)--Path
         |
  (In variable value use)C:\Program Files\nodejs
         |
        ok 

After that just restart you terminal

David Buck
  • 3,752
  • 35
  • 31
  • 35
0

chances are that you messed up with your system path, if it's the case, a very straight forward solution will be re-installing node and npm but don't forget to close and re-open powershell/cmd

Note: i thought that restarting computer has no effect on path but in an accident someone just deplug my laptop from power and after i turned it on everything was repaired and OK!

0

I've got the same error. Simply check below instructions. If all they are done. Just restart your computer. Then it will worked for me. I just restarted my computer.

  1. List item

  2. Missing Node.js software

  3. Wrongly updated Windows environment path

  4. Installed in the wrong path

0

1.find nodejs folder

  1. go to environment variable in windows

  2. edit path and add "find nodejs folder"

  3. Restart computer enter image description here

Slava Rozhnev
  • 9,510
  • 6
  • 23
  • 39
0

This issue corrected after updated my environment variable path i just copy the path from path value in user to path value in system check image attachment.

https://i.stack.imgur.com/11uCk.png

path change image below

Maniraj
  • 33
  • 5
0
  1. Go to Control Panel\System and Security\System on Windows 10.

  2. Go to advance properties.

  3. Advance system settings -> advance system settings -> Environment Variables Or type edit the system environment variables in the windows search.

  4. Add "C:\Program Files\nodejs" ,"C:\Program Files\nodejs" and "C:\Program Files\nodejs\node_modules\npm\bin" to the user and system variable (path)

  5. restart the cmd and run again.

Hope it will work.

Ashutosh Patole
  • 926
  • 1
  • 7
  • 23
Ishaat171
  • 1
  • 1
0

if you are getting this error after installing node with nvm-windows, then you have forgotten to run the command nvm use 19.3.0 use whichever version you have installed

Akshay Vijay Jain
  • 13,461
  • 8
  • 60
  • 73
0
  1. Uninstall all previous versions of node, if any.
  2. Install nvm-windows. Go to releases, download nvm-setup.exe from the latest release.
  3. Install using administrative privileges.
  4. Run PowerShell as Administrator. Run nvm -v in the PowerShell to see the installed version of nvm-windows
  5. Run nvm ls to see the list of installed versions of node. There should be none, as you have just installed nvm
  6. Run nvm on to enable nvm, and set path variables
  7. Now you can use nvm the same way, you would on Ubuntu or Mac.
    1. Run nvm install 18 to install node v18
    2. Switch between node versions using node use {node-version}. e.g. To switch to node 16, run nvm use 16
Vishal Kumar
  • 403
  • 4
  • 13
0

Was looking for a solution about an hour, this actually worked: This manually resets the path variable in the specific PowerShell terminal.

$env:Path = `
[System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + `
[System.Environment]::GetEnvironmentVariable("Path","User")
nicklin
  • 1
  • 1
0

I put my node file that I had downloaded the latest version next to the javascript file and solved my problem.

  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Aug 16 '23 at 18:37
-1

Reinstall/repair the application and close the vs code powershell

Sharath BR
  • 19
  • 1