react developer
react developer

Reputation: 71

npm : The term 'npm' is not recognized as the name of a cmdlet, function, script file, or operable program

*when i check node -v it's alright and prints out. But npm is shows this error. How can I fix this? Please help me. *

enter image description here

Upvotes: 6

Views: 168616

Answers (10)

Solomon Suraj
Solomon Suraj

Reputation: 1314

Once you have installed nodejs, restart the laptop.

Then set the path (system properties -> environment settings -> C:\Program Files\nodejs)

Now open cmd and type -> C:\Users\solomon\Desktop\react-project>npm start, it will work by opening browser with http://localhost:3000

Alternatively, if npm does not work in Visual studio code, open VS code then press Ctrl+P and type ext install npm script runner. You have to choose one and install it.

Once installed, restart Visual studio code, go to VS code terminal and type npm start and browser will start http://localhost:3000.

Upvotes: 8

Emile
Emile

Reputation: 11721

When you get this error on windows and all existing solutions seem to be correct, i.e. you've

  • Checked environment your variables which are correct
  • Restarted your PC
  • Checked nvm --version and get a resonse
  • Tried npm --version fails as above.

Then try the following.

  • Delete c:/users/YourUserName/AppData/Roaming/npm
  • Also delete c:/users/YourUserName/AppData/Roaming/npm-cache for good measure.
  • Go to a project directory where you'd do say npm install but instead do.
  • nvm ls to see which versions of node you have
  • nvm use 22.9.0 for example.

This should hopefully fix the npm.

Note: you might just try nvm use [versionNumer] first before deleting the folders in AppData, but if that failes, then just delete them and hope nvm fixes it for you.

Upvotes: 0

I was very frustrated of this issue when I got this error while installing Tailwind CSS. what you need to do is INSTALL Node.js for your platform. https://nodejs.org/en/download/

Upvotes: 0

Hashan Malinda
Hashan Malinda

Reputation: 31

  1. First close the IDE
  2. Then open Edit the system environment variables and click environment variables -> system variables.
  3. go to the Path and click new
  4. Add the path as C:\Program Files\nodejs
  5. Finally the error is fixed and run npm start

Upvotes: 3

Ace Flame
Ace Flame

Reputation: 1

I had this issue and all I had to do was restart my computer.

Upvotes: -1

H_Shawky
H_Shawky

Reputation: 1

make sure you've installed the node package manager -> navigate to start menu 1- search for "Environment Variables". 2- navigate to "System Variable" Box. 3- Click on "PATH" -> "Edit" 4- Press New -> Browse 5- Add The Path of the node (Most Likely you'll find it in 'C:/ program files')

Upvotes: 0

Moses
Moses

Reputation: 11

This is how I solved it. Incase of next time

Open the Control Panel (Click the Start button, then click Control Panel)

Click User Accounts

Click Change my environment variables

Select PATH and click the Edit... button At the end of the Variable value, add; C:\Program Files\nodejs

Click Ok on the "Edit User Variable" window, then click Ok on the "Environment Variables" window

Start a command prompt window (Start button, then type cmd into the search and hit enter)

At the prompt (C:>) type npm and hit enter; you should now see some help text (Usage: npm etc.) rather than "npm is not recognized..." Now you can start using npm!

Upvotes: 1

A.K.J.94
A.K.J.94

Reputation: 552

I got a similar situation like run on windows shell throws error but run on other bash terminal gets running successfully

Upvotes: 0

Alkemichar
Alkemichar

Reputation: 81

I'm using nvm for the usage of the different versions of node. As a fresh installation, I've installed node version X but didn't apply "use" command for this node version.

Command "nvm ls" should return an asterisk before the current node version.

Upvotes: 0

npm : The term 'npm' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1

  • npm install
  •   + CategoryInfo          : ObjectNotFound: (npm:String) [], CommandNotFoundException       
      + FullyQualifiedErrorId : CommandNotFoundException
    

Upvotes: 0

Related Questions