foo-baar
foo-baar

Reputation: 1104

-bash: npm: command not found, WHY?

While experimenting with oh-my-zsh and zsh, I managed to delete terminal com.apple.terminal.*, .bash_profile.

After fixing everything, my terminal is not recognising any command. When I type npm, it shows:

-bash: npm: command not found

So does for all other installed packages like dotnet core.

Is there any way to fix it?

Upvotes: 3

Views: 4982

Answers (1)

nbari
nbari

Reputation: 27005

Probably you just need to edit your $PATH variable and set again the paths.

You could check your current $PATH by doing:

echo -e ${PATH//:/\\n}

That will list your existing paths, and probably there will be missing some $HOME/paths

Is that the case just add them based on your requirements, in macOS for node/npm would be something like:

export PATH="$HOME/node_modules/.bin:$HOME/Library/Python/2.7/bin:$HOME/Library/Python/3.6/bin:$PATH"

This will give priority to the files located in $HOME/node_modules/.bin

In case you uninstalled or removed node you could try this:

brew update && brew install node

Upvotes: 3

Related Questions