npm command not found (2024)

Npm (node package manager) helps JavaScript developers focus on the code instead of other — sometimes tedious and repetitive — details. Sometimes, however, you may come across npm errors such as npm command not found.

We will work through how to resolve this error, so you can go back to enjoying all that npm has to offer.

npm command not found (1)

Find Your Bootcamp Match

  • Career Karma matches you with top tech bootcamps
  • Access exclusive scholarships and prep courses










By continuing you agree to our Terms of Service and Privacy Policy, and you consent to receive offers and opportunities from Career Karma by telephone, text message, and email.

What is the npm command not found Error?

The Npm command not found error can appear when you install or upgrade npm.

On Windows, the cause of this error could be that a PATH or system variable is not correctly set. The error can also occur if you do not have npm or Node.js installed, have an outdated version, or have permission issues.

Mac users seeing the npm command not found error could be due to missing files on your computer or a permissions issue.

This article addresses those possible reasons. First we cover general causes related to installation, then go into Mac-specific solutions, before addressing how to fix a potential missing PATH variable on Windows.

Check if npm is Installed

The npm command requires npm to be installed on Windows. Npm uses Node.js, so it comes included in your Node.js installation package. To check if you have NOde.js installed type the following in the terminal:

node -v

The -v stands for “version”. Visit the npm site to verify if the version of npm you have installed is the latest version.

You may have accidentally deleted your npm file or moved its location. This can happen more often than you think, especially if you change your PATH on your system.

Check if npm is installed as well as node by typing the following in your terminal:

npm -v

If you do have npm installed, it will output the version on your computer. To install npm, run the commands here for Mac and here if you are using Windows.

Update npm

Even though npm comes with Node.js, they are separate, meaning you can have the latest of one and not of the other, since they may have different update release dates.

If you have node (check with $node -v) and your node commands work, you may need to simply update npm. Updating npm can be done with one line:

npm install npm@latest -g

If you have trouble with this command, you may have to prefix it with sudo:

sudo npm install -g npm@latest

If you are working on your code in an editor, make sure to restart it after you’re done installing or updating.

Windows Solution

You may still see npm command not found because C:\Program Files\nodejs could be missing from your PATH environment variable.

  1. Open global search 🔎 and look up “Environment Variables”.
  2. Choose “Edit system environment variables”.
  3. Click “Environment Variables” in the “Advanced” tab.
  4. In the “System Variables” box, search for Path and edit it to include the path C:\Program Files\nodejs. If you don’t see it there click “New” then add this path. (Note: Depending on your version you may just need to edit and append this path to what’s there by prefixing it with a semicolon. You’ll see the other paths there are also separated by semicolons).

Here is some documentation on the Windows settings and environment variables relating to npm in case you are curious and want to read more about the settings.

Permissions Solution

For permission issues, prefix your terminal commands with sudo to bypass issues. Permission issues can be the cause of program files not being able to be properly downloaded. You can also try the following terminal commands as a last option if all others have not worked out for you, though this may not be an option for you if you are on a shared or work computer. For Mac and Linux users:

sudo chown -R $(whoami):admin /usr/local/lib/node_modules/

This command adjusts the permissions of the npm directory. Chown means change owner, -R means recursively (throughout the files therein), “whoami” grabs your user account name, and the last line is where your node package files are. After running the above command, try the npm command you were attempting again.

Conclusion

After implementing any changes we went through to troubleshoot the “command not found” error, be sure to restart any open code editor or terminal/command prompt. To recap, the suggested solutions we discussed were:

  • updating npm
  • checking if node is up to date
  • fixing the PATH in Windows
  • changing permissions for node

This article has instructional links on how to uninstall and install npm for Windows or Mac. If you can do this, it may clear any blockers npm is having.

If you want to dive into npm, read this article on npm which includes curated, proven resources for learning more.

npm command not found (2024)

FAQs

How do I install npm? ›

Installation of NodeJS and NPM is straightforward using the installer package available at NodeJS official web site.
  1. Download the installer from NodeJS WebSite.
  2. Run the installer.
  3. Follow the installer steps, agree the license agreement and click the next button.
  4. Restart your system/machine.
Jan 10, 2019

Why is npm run not working? ›

When you get the above error, it means that you don't have a package. json file in the directory that you tried running npm start in. This will create a package. json file in the current directory after you complete the inputs.

How to check if npm is installed? ›

To see if NPM is installed, type npm -v in Terminal. This should print the version number so you'll see something like this 1.4.28.

How enable npm install? ›

How to Install Node.js and NPM on Windows
  1. Step 1: Download Node.js Installer. In a web browser, navigate to https://nodejs.org/en/download/. ...
  2. Step 2: Install Node.js and NPM from Browser. Once the installer finishes downloading, launch it. ...
  3. Step 3: Verify Installation.
Oct 28, 2019

How to install npm in terminal? ›

To install a package, npm uses the following algorithm:
  1. load the existing node_modules tree from disk.
  2. clone the tree.
  3. fetch the package.json and assorted metadata and add it to the clone.
  4. walk the clone and add any missing dependencies.
  5. dependencies will be added as close to the top as is possible.
Jun 14, 2018

Why can't I npm install? ›

The main cause of the npm command not found error is that npm is not installed. You can run the command “npm -v” to check whether npm is installed. If not, I recommend you uninstall Node. js and then reinstall node.

Why npm is not installing? ›

The Npm command not found error can appear when you install or upgrade npm. On Windows, the cause of this error could be that a PATH or system variable is not correctly set. The error can also occur if you do not have npm or Node. js installed, have an outdated version, or have permission issues.

Where do I install npm? ›

NPM installs global packages into /<User>/local/lib/node_modules folder. Apply -g in the install command to install package globally.

How to start npm command? ›

The Basics: Getting started with npm
  1. Using npm init to initialize a project.
  2. Using npm init --yes to instantly initialize a project.
  3. Install modules with npm install.
  4. Install modules and save them to your package.json as a dependency.
  5. Install modules and save them to your package.json as a developer dependency.
Feb 10, 2022

How do I enable npm on Windows? ›

How to Install Node.js and NPM on Windows?
  1. Step 1: Download the Installer. Download the Windows Installer from NodeJs official website. ...
  2. Step 2: Install Node.js and NPM. After choosing the path, double-click to install .msi binary files to initiate the installation process. ...
  3. Step 3: Check Node.js and NPM Version.
Oct 6, 2022

How to install npm and node? ›

Visit the official node. js site https://nodejs.org/en/download/ and click on Windows installer to download the necessary software in your system. The installer contains the NPM package. Based on the system you want to install, choose 32-bit installer or 64-installer and proceed.

Does npm need to be installed? ›

To publish and install packages to and from the public npm registry or a private npm registry, you must install Node. js and the npm command line interface using either a Node version manager or a Node installer. We strongly recommend using a Node version manager like nvm to install Node.

Is npm I npm install? ›

There is no difference, since "npm i" is an alias for "npm install". They both do the exact same thing (install or update all the dependencies in your package-lock. json).

Is npm I the same as install? ›

npm i: The npm i (or npm install) is used to install all dependencies or devDependencies from a package. json file. npm ci: CI stands for clean install and npm ci is used to install all exact version dependencies or devDependencies from a package-lock.

Why is npm install not working on CMD? ›

The error “npm is not recognized as an internal or external command” error may occur because either the npm is not installed or it is not added to the windows path. To resolve this error, the first solution is to install Node. js on Windows as Node. js is equipped with npm by default.

How do I start npm locally? ›

Visit your (local) website!
  1. Step 1: Go to the NodeJS website and download NodeJS. ...
  2. Step 2: Make sure Node and NPM are installed and their PATHs defined. ...
  3. Step 3: Create a New Project Folder. ...
  4. Step 4: Start running NPM in your project folder. ...
  5. Step 5: Install Any NPM Packages: ...
  6. Step 6: Create an HTML file.
Feb 22, 2021

How to use npm command? ›

Here's a list of the most common commands you'll use when working with npm .
  1. Install package. json dependencies. ...
  2. List globally installed packages. npm list -g --depth=0.
  3. Uninstall global package. npm -g uninstall <name>
  4. Upgrade npm on Windows. npm-windows-upgrade.
  5. list available scripts to run. ...
  6. Update npm. ...
  7. Installed version.
Feb 1, 2020

How do I open npm in terminal? ›

Open up a command prompt and navigate to your calculator directory Run npm init to create a new Node. js project. Use the default answer to every question it asks you (just press "Enter") - don't worry if you don't understand what all the questions mean!

What is npm in command line? ›

npm is the package manager for the Node JavaScript platform. It puts modules in place so that node can find them, and manages dependency conflicts intelligently.

What is npm install option? ›

The npm install command will create a node_modules folder in the current directory (if it doesn't exist already), and download the package to that directory. If you want to install the package and also add it to the dependency list in the package.json file, then you can use --save option - npm install my-package --save.

Can I reinstall npm? ›

If the npm or Node. js running on your Windows environment is broken, you can reinstall and get the most out of them. You can use any of the following methods: Reinstalling using a Node version manager.

Can we install npm without node? ›

npm requires Node. js. If you don't have Node. js installed, we recommend you install the LTS version from the Node.

How to install npm separately? ›

Follow the steps mentioned below for installation of Node.js and NPM using the ".pkg" installer:
  1. Step 1: Download the Node.js ".pkg" Installer. ...
  2. Step 2: Run the Node.js Installer. ...
  3. Step 3: Verify successful installation of Node.js. ...
  4. Step 4: Update Your npm Version. ...
  5. Step 5: Set NODE HOME in Environment Variable.
Nov 16, 2021

Where is npm located in Windows? ›

Type in npm root -g to see what the current path your npm is installed to. Next use npm config set prefix and your npm path will be changed to whatever directory you are currently on.

How to initialize npm? ›

Creating a default package. json file
  1. On the command line, navigate to the root directory of your package. cd /path/to/package.
  2. Run the following command: npm init --yes.

How do I get npm access? ›

Scoped packages default to restricted, but you can either publish them as public using npm publish --access=public , or set their access as public using npm access public after the initial publish. You must have privileges to set the access of a package: You are an owner of an unscoped or scoped package.

How do you check if node and npm are installed? ›

Checking if Node & NPM are Installed
  1. Test Node. To see if Node is installed, open the Windows Command Prompt, Powershell or a similar command line tool, and type node -v . ...
  2. Test NPM. To see if NPM is installed, type npm -v in Terminal. ...
  3. Create a test file and run it. A simple way to test that node.
Jan 8, 2015

How do I download and install NPM packages? ›

Downloading a package is very easy. Open the command line interface and tell NPM to download the package you want. Now you have downloaded and installed your first package! NPM creates a folder named "node_modules", where the package will be placed.

When should I run npm install? ›

npm install simply reads your package. json file, fetches the packages listed there from (usually) https://www.npmjs.com/ , and sometimes engages in the build steps for those packages. So you only have to run npm install when you change your package. json file, and need to fetch new dependencies.

How to update npm on windows? ›

Using NPM:
  1. Open the Terminal and check your current Node version: node -v.
  2. Install n package using the following command: npm install -g n. ...
  3. To update Node, run the following command in your terminal: n latest. ...
  4. Now you can verify that your update is complete by rechecking your Node version: node -v.
Dec 21, 2022

Is NPM package installed? ›

You can also use the npm list -g followed by the package name to see whether a given package is installed globally or not.

How to install npm globally? ›

To install a module from npm globally, you'll simply need to use the --global flag when running the install command to have the module install globally, rather than locally (to the current directory). Note: One caveat with global modules is that, by default, npm will install them to a system directory, not a local one.

How to install npm in Windows? ›

Visit the official node. js site https://nodejs.org/en/download/ and click on Windows installer to download the necessary software in your system. The installer contains the NPM package. Based on the system you want to install, choose 32-bit installer or 64-installer and proceed.

How to add npm to path? ›

Search for Environment Variables in the Windows search. "Edit the System environment variables" option will be popped in the result. Open that, select the "Path" and click on edit, then click "New" add your nodeJS Bin path i.e in my machine its installed in c:\programfiles\nodejs\node_modules\npm\bin.

How do I run npm in command prompt? ›

Configuring the Step
  1. Add the Run npm command Step to your Workflow preceding any build Step.
  2. Set the Working directory.
  3. Set the command you want npm to execute, for example install to run npm install in the The npm command with arguments to run input.

Why npm is not working in CMD? ›

The error “npm is not recognized as an internal or external command” error may occur because either the npm is not installed or it is not added to the windows path. To resolve this error, the first solution is to install Node. js on Windows as Node. js is equipped with npm by default.

Where is npm installed in Windows? ›

The prefix config defaults to the location where node is installed. On most systems, this is /usr/local . On Windows, it's %AppData%\npm .

Do I need to install node to install npm? ›

To publish and install packages to and from the public npm registry or a private npm registry, you must install Node.js and the npm command line interface using either a Node version manager or a Node installer. We strongly recommend using a Node version manager like nvm to install Node.js and npm.

Can you install node without npm? ›

We can install modules required for a particular project in node. js without npm, the recommended node package manager using yarn. Yarn is a wonderful package manager.

Top Articles
Latest Posts
Article information

Author: Fr. Dewey Fisher

Last Updated:

Views: 5854

Rating: 4.1 / 5 (42 voted)

Reviews: 81% of readers found this page helpful

Author information

Name: Fr. Dewey Fisher

Birthday: 1993-03-26

Address: 917 Hyun Views, Rogahnmouth, KY 91013-8827

Phone: +5938540192553

Job: Administration Developer

Hobby: Embroidery, Horseback riding, Juggling, Urban exploration, Skiing, Cycling, Handball

Introduction: My name is Fr. Dewey Fisher, I am a powerful, open, faithful, combative, spotless, faithful, fair person who loves writing and wants to share my knowledge and understanding with you.