Bash npm command not found что делать
Перейти к содержимому

Bash npm command not found что делать

  • автор:

npm command not found in zsh but found in bash

I installed npm with nvm and the first time it went all great, now I tried to check npm version on Mac terminal an it shows:

% npm --version zsh: command not found: npm 

But using VSCode terminal with bash, with same command, shows:

npm --version 6.14.12 

Is there a chance I installed the wrong way npm or nvm ? Or is this a way I can tell Mac terminal to use bash instead of zsh?

asked Nov 2, 2021 at 23:08
123 1 1 gold badge 1 1 silver badge 5 5 bronze badges
Your PATH’s are in sync. Run ‘echo $PATH’ in both zsh and bash. I’m sure there’s something missing.
Nov 3, 2021 at 1:22

bash: /Users/myuser/.nvm/versions/node/v12.22.1/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin zsh: /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

Nov 3, 2021 at 1:53

2 Answers 2

So your PAth’s are not the same. This is what is causing your different terminals to not be in sync.

They both have this:

 bash: /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin zsh: /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin 

But only your bash has this:


You should add that to your ZSH PATH. Since you don’t have a .zshrc file, do the following in Terminal;

echo 'PATH="~/.nvm/versions/node/v12.22.1/bin:$PATH"' >> ~/.zshrc 

answered Nov 3, 2021 at 2:32
1,204 1 1 gold badge 6 6 silver badges 15 15 bronze badges

Can you please instruct me on how to add that path to zsh? I’m quite new using MacOS and zsh. I’ve been reading that I must add $HOME/.nvm/versions/node/v12.22.1/bin to my .zshrc file but when I do cat to that file it doesn’t exist. cat ~/.zshrc shows cat: /Users/myuser/.zshrc: No such file or directory . Should I create the file and add this PATH? Works the same way?

Nov 3, 2021 at 4:43
No problem, check above, I edited the post.
Nov 3, 2021 at 13:12

I already execute that command in terminal and cat ~/.zshrc shows PATH=»~/.nvm/versions/node/v12.22.1/bin:$PATH» but still showing command not found even after reseting terminal. Also echo $PATH still showing the same path showed in comment above.

Nov 3, 2021 at 15:05

I checked echo $PATH again in zsh and it now show ~/.nvm/versions/node/v12.22.1/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

Почему выдает ошибку bash: npm: command not found?

Я установил пакет Laravel Breeze командой php artisan breeze:install . После этого мне выдало Breeze scaffolding installed successfully.
Please execute the «npm install && npm run dev» command to build your assets. Я ввожу npm install и мне пишет ошибку bash: «npm: command not found» . Почему это происходит, и как это можно решить?

  • Вопрос задан более года назад
  • 2062 просмотра

1 комментарий

Простой 1 комментарий

How to fix the NPM command not found error?

In this article, we will go through different solutions that can help you fix the common issue «npm command not found» effortlessly.

Download PDF
Posted: 31 Jan, 22 Updated: 11 May, 23 by Susith Nonis 5 Min

How to fix the NPM command not found error?

List of content you will read in this article:

NPM is a top-rated package manager for Node.js applications. However, in some cases, a user may find trouble installing it or, by any chance, finds it difficult to resolve the “npm package missing” error. This article will go through different solutions that can help you fix this common issue quickly.

What is NPM

NPM, or Node Package Manager, is a NodeJS package manager. A package manager allows you to specify the dependencies for your project, stating that this tool or site requires these specific third-party components in order to run (or develop). It will then figure out what they need and download it for them automatically. The following are major advantages of using the npm package manager:

  • It deals with recursive dependencies.
  • The dependencies can be re-assembled as needed and do not need to be stored in your repository.
  • You can easily specify and change the version of these packages on which you rely.

What Causes the NPM command not found Error?

The «npm command not found» error typically occurs when the Node.js package manager (npm) is not properly installed or its executable is not added to the system’s PATH environment variable. Here are a few possible causes for this error:

Node.js not installed

If Node.js is not installed on your system, it will not include npm by default. You need to install Node.js, which includes npm as a package manager.

Incomplete installation

If Node.js is installed but npm is missing, it may be due to an incomplete installation. In some cases, when you download Node.js, it might exclude npm or encounter errors during the installation process.

Incorrect PATH configuration

The PATH environment variable is a list of directories where the operating system looks for executable files. If the directory containing the npm executable is not included in the PATH variable, the system won’t be able to locate and execute npm.

Operating system-specific issues

On some operating systems, there can be additional configuration steps required to ensure npm is accessible. For example, on macOS and Linux, you may need to use a package manager like Homebrew or nvm (Node Version Manager) to install Node.js and npm.

Corrupted installation or conflicts

In rare cases, a corrupted installation or conflicts with other software on your system can lead to the «npm command not found» error. This can happen if there are multiple installations of Node.js or if there are conflicts with other package managers.

Solutions to the “npm command not found” error

This is a standard error that people face in any Operating System. There can be many reasons for this error: system or path variable has been modified, installation mistake, permission issue, etc. Let’s look at possible fixes for this error.

Solution 1 on Windows

Go to this website and download Node.js. Select “Windows Installer” with the “.msi” extension and choose your suitable architecture from 64 or 32-bit options.

Once Node.js has been installed, the installation procedure will start. Accept the terms and click on Next.

The following dialogue will ask you for the location of the installation of Node.js. Choose any location that suits you.

The following window will ask you to install additional tools along with Node.js. Leave it as the default unless very necessary.

The following window will ask you to install Chocolatey along with Node.js. Again, leave it as the default unless very necessary.

The following window will ask you to start the installation. Click on Install. The installation will then begin.

After installation, verify the npm installation using the following command

Solution 2 for Windows

The path variables are by default added in Windows while installing Node.js. However, some other processes can cause it to get removed or modified.

To fix this, go to Edit the system environment variables from the Start menu.

A new dialogue box saying System Properties will appear. Click on the Environment Variables option from it.

Select the option named Path from the list and click on Edit.

If the path for Node.js is not present, click on New and paste the location of the Node.js folder. In our case, it was “C:\Program Files\nodejs.”

Solution 1 for UNIX-like systems

For Linux users, type the following sequence of commands to install npm and Node.js

$ sudo apt-get update

$ sudo apt-get install nodejs

$ sudo apt-get install npm

Solution 2 on UNIX-like systems

There can be permission issues in UNIX-like systems.

To give the required permission to the user, type the below commands on respective Operating Systems and press Enter .

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

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

Solution 3 on UNIX-like systems

You might also not be using the latest version of npm. Run the following command to upgrade npm:

$ sudo npm install npm@latest -g


This article went through various solutions for the “npm command not found” error. We saw how we could install it from scratch and configure some settings if it is already installed and fix this issue. We covered aspects like permission issues, installation issues, path variable issues to fix this error.

People also read:

  • How to install Node.js and NPM
  • How to update the NPM package manager
  • How to check the NPM version

Saved searches

Use saved searches to filter your results more quickly

Cancel Create saved search

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

npm / npm Public archive

Mac OS X NPM install probem «-bash : npm: command not found» #3125

yramagicman opened this issue Feb 2, 2013 · 70 comments

Mac OS X NPM install probem «-bash : npm: command not found» #3125

yramagicman opened this issue Feb 2, 2013 · 70 comments


yramagicman commented Feb 2, 2013

I have recently installed node.js on my Mac (10.8) via the package installer. The installer provides node and npm. I’ve run into an issue though, when I run npm, no matter what I’m doing, I get the error quoted in the title. (see screenshot below)

Screen Shot 2013-02-02 at 5 45 24 PM

The funny thing is that node.js works. (again see screenshot below)

Screen Shot 2013-02-02 at 5 47 31 PM

I’ve tried installing npm via shell, and once I circumvented the permissions error I was running into, npm installed, and still gave me an error.

Screen Shot 2013-02-02 at 5 51 15 PM

The only hint I have to what the problem might be is in the following screenshot.

Any ideas? I hope I’ve provided sufficient info to fix this issue. If you need any more info, please let me know. If this is the wrong place to submit this issue I apologize, I’ve never submitted an issue on Github before.

The text was updated successfully, but these errors were encountered:

yramagicman commented Feb 3, 2013

Here’s the output:

Jonathans-MacBook-Pro:~ jdg$ hash - Jonathans-MacBook-Pro:~ jdg$ which node /usr/local/bin/node Jonathans-MacBook-Pro:~ jdg$ node -pe process.execPath /usr/local/bin/node Jonathans-MacBook-Pro:~ jdg$ which npm Jonathans-MacBook-Pro:~ jdg$ 

yramagicman commented Feb 3, 2013

For some dumb reason. the code didn’t parse as code. Probably PEBKAC. I’m pretty sure I did the 4 spaces thing.

edef1c commented Feb 3, 2013

(FTFY, you need an empty line in between)

yramagicman commented Feb 3, 2013
isaacs commented Feb 4, 2013

How did you install node? What does this output?

ls -laF /usr/local/bin/npm 

On Sunday, February 3, 2013, yramagicman wrote:


Reply to this email directly or view it on GitHub

yramagicman commented Feb 4, 2013

I installed node via the package installer available at Then I attempted to install npm via the shell script you provided. Nothing there worked, so I rebooted to no avail. Then I deleted node and related files and tried again, also to no avail. Now I’m here, talking to people smarter than me. 🙂

Jonathans-MacBook-Pro:~ jdg$ ls -laF /usr/local/bin/npm lrwxr-xr-x 1 root wheel 38 Feb 2 16:33 /usr/local/bin/npm@ -> ../lib/node_modules/npm/bin/npm-cli.js 

yramagicman commented Feb 11, 2013

just tried the package installer again, to no avail. If you guys have any ideas, I’d love to get this working.

mfncooper commented Feb 11, 2013

I’d bet that the path at the far end of that symlink (i.e. ../lib/node_modules/npm/bin/npm-cli.js ) doesn’t exist, perhaps because the installer couldn’t write to /usr/local/lib . You could try making sure all npm artifacts are gone from both /usr/local/bin and /usr/local/lib and then re-installing, being sure to use sudo when doing that.

yramagicman commented Feb 11, 2013

@mfncooper You were right. It was a permissions problem! No one had access to the file. Ran chmod on /usr/local/lib and set permissions to give full access to everyone. Then I ran the shell script again as a sudo user. Worked perfectly. Thanks.

mfncooper closed this as completed Feb 11, 2013
brugos commented Mar 21, 2014

I have the same problem after trying to update node without sudo privileges.
And I solved the problem like an ‘ex-windows’ user: Installed Node package again .
Thanks Bill 😉 !

tadmacy commented Apr 15, 2014

Thanks, brugos. The final step was to uninstall with brew and reinstall after I bounced between ‘brew link —overwrite —dry-run node’ and ‘chmod’ or ‘chgrp’ to fix various permissions.

ownsourcing commented Aug 23, 2014

what worked for me, in case it helps someone:

$ brew update $ brew uninstall node $ brew install node $ sudo brew postinstall node # brew error message provided this recommendation; only worked with sudo 

to test that npm is working (tho appears to build an index, which not everyone may want):
$ npm search # returns long list of packages

duranmla commented Aug 26, 2014

I’m on the same issue, sorry I’m quite new with OSX @yramagicman what did you do? I mean I know what is chmod and I barely understand what’s going on but, what was the actual command to solve this issue?

yramagicman commented Aug 26, 2014

I believe the command was chmod 777 /usr/local/lib but honestly @ownsourcing has the better solution. Use homebrew to install node, then you get updates easier, plus brew doctor is the bees knees.

DomT4 commented Aug 26, 2014

Note that switching between the Node pkg and Homebrew’s Node installation will cause permission hell. If you’re going to make the switch, and you don’t mind losing your installed packages, I’ve drawn up a deliberately methodical bash script here which purges Node & all its remnants from the system. After running that script, you should be able to install the Homebrew Node without any post-install issues or need for sudo .

Nodraak commented Aug 27, 2014
duranmla commented Aug 28, 2014

Thanks guys, well I try the brew solution and sort of everything start to work, I stumble with some issue with ONE package. I’m trying to solve it but I don’t understand this thing. My issue is #6051

albertpak commented Sep 12, 2014

Thank you @ownsourcing — brew solution worked

JGallardo commented Oct 18, 2014

I found this by searching on Google for -bash : npm: command not found and wow so much that has to be sorted through in this thread. I figured it out from piecing other things and wrote this answer on stackoverflow.

Follow that, then brew update then brew install npm .

camwes commented Oct 21, 2014

seconding @ownsourcing, chowning an entire directory is easier but probably not a good idea.

ericmwalsh commented Nov 19, 2014

Here are the step by step ways I solved this issue. I used ‘brew’ to install node and ran into this issue exactly: the node command worked but not the npm command

sudo brew uninstall node
brew update
brew upgrade
brew cleanup
brew install node
sudo chown -R myusername /usr/local
brew link —overwrite node
sudo brew postinstall node

I pieced together this solution after trial and error using this thread and this site:

DomT4 commented Nov 19, 2014

FWIW: Homebrew doesn’t recommend the use of sudo for anything, including the postinstall. Try to find better ways around the issue rather than enforcing sudo onto Brew if possible.

adrazich commented Nov 19, 2014

I had the same issue. @ownsourcing ‘s solution worked for me.

g-francesca commented Nov 28, 2014

@ownsourcing’s solution worked for me too.
Now I have the same issue when trying to install bower.

This is the command I run:
npm install -g bower

 npm ERR! Darwin 13.3.0 npm ERR! argv "node" "/usr/local/bin/npm" "install" "-g" "bower" npm ERR! node v0.10.31 npm ERR! npm v2.1.10 npm ERR! path /Users/francesca/.node/bin/bower npm ERR! code EACCES npm ERR! errno 3 npm ERR! Error: EACCES, unlink '/Users/francesca/.node/bin/bower' npm ERR! < [Error: EACCES, unlink '/Users/francesca/.node/bin/bower'] npm ERR! errno: 3, npm ERR! code: 'EACCES', npm ERR! path: '/Users/francesca/.node/bin/bower' >npm ERR! npm ERR! Please try running this command again as root/Administrator. npm ERR! error rolling back Error: EACCES, unlink '/Users/francesca/.node/bin/bower' npm ERR! error rolling back < [Error: EACCES, unlink '/Users/francesca/.node/bin/bower'] npm ERR! error rolling back errno: 3, npm ERR! error rolling back code: 'EACCES', npm ERR! error rolling back path: '/Users/francesca/.node/bin/bower' >npm ERR! Darwin 13.3.0 npm ERR! argv "node" "/usr/local/bin/npm" "install" "-g" "bower" npm ERR! node v0.10.31 npm ERR! npm v2.1.10 npm ERR! Uncaught, unspecified "error" event. npm ERR! npm ERR! If you need help, you may report this error at: npm ERR! npm ERR! Please include the following file with any support request: npm ERR! /npm-debug.log 

DomT4 commented Nov 28, 2014

Yup. That is pretty much expected when you sudo npm in the post-install :/. Once you give it those permissions it’s hard to take them away again without everything throwing a tantrum. You can try sudo chown -R whoami ~/.node which sometimes helps. Sometimes the permission problem extends further than that though.

kitefishlabs commented Dec 9, 2014

Should I be disturbed by the fact that I do not have ~/.node? I do have ~/.npm. Is .npm a replacement for node or should I be looking elsewhere for a .node directory? I just went through and looked at directory permissions, and am basically reinstalling everything without sudo (carefully removing things with the wrong perms set). It seems as though in my inexperience with node/npm, resorted to using sudo at times. Once you sudo brew something, you’ve introduced permission errors into future installs.

DomT4 commented Dec 9, 2014

Nope, that’s nothing to worry about. Sometimes you find a .node directory in $HOME , sometimes you find a .node-gyp directory, you will always find an .npm directory. Sometimes, you find all three, or any mix of the above. If everything is functioning alright, don’t worry about it too much.

But yeah, Brew tries to exist without going near sudo as much as possible, because the latter always causes permission problems unless brew is also owned by root , which Brew doesn’t recommend for various issues around installing things from package-managers with root .

nastaas commented Dec 16, 2014

So I tried the @ownsourcing ‘s solution. And then the npm search gave this result:

npm ERR! argv "node" "/usr/local/bin/npm" "search" npm ERR! node v0.10.33 npm ERR! npm v2.1.11 npm ERR! code E200 npm ERR! [object Object] [object Object]: -/all npm ERR! npm ERR! If you need help, you may report this error at: npm ERR! npm ERR! Please include the following file with any support request: npm ERR! /Users/nastaas/npm-debug.log` **Then the installation of the bower went all wrong** `npm install -g bower npm WARN locking Error: EACCES, open '/Users/nastaas/.npm/_locks/bower-e8debc5417026b57.lock' npm WARN locking /Users/nastaas/.npm/_locks/bower-e8debc5417026b57.lock failed < [Error: EACCES, open '/Users/nastaas/.npm/_locks/bower-e8debc5417026b57.lock'] npm WARN locking errno: 3, npm WARN locking code: 'EACCES', npm WARN locking path: '/Users/nastaas/.npm/_locks/bower-e8debc5417026b57.lock' >npm ERR! Darwin 14.0.0 npm ERR! argv "node" "/usr/local/bin/npm" "install" "-g" "bower" npm ERR! node v0.10.33 npm ERR! npm v2.1.11 npm ERR! Attempt to unlock /usr/local/lib/node_modules/bower, which hasn't been locked```` What shall I do? 

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *