Zshrc "command not found: npm"

So I'm learning node.js. I am following this tutorial to install it and try some things.

Anyway, npm behaves really weird. It will work fine for a while (I changed its viewer configuration settings, for example), but then it suddenly “disappears”, so the next time I enter

npm ...(anything)

on the command line, my shell tells me that the npm command was not found. Uninstalling and then reinstalling npm using nvm used to work, but I would prefer not to do it every ten minutes, and it’s very strange for me that it suddenly stops working.

I think the last time it stopped working after I edited and then processed the ~ / .zshrc file - just added npm and node tab completion plugins.

Any idea what is going on? I will post the results of a few basic commands, but I am really poor at sysadmin, and I really don't know what to look for here.

nvm -ls

   v0.8.22
current:    v0.10.2
default -> 0.8 (-> v0.8.22)

which node

/usr/bin/node

where npm

npm not found

My root folder has both nvm (is it a duplicate?) And npm directories.

If I go to / usr / bin, node is a file, not a directory. There is also an npm file, but not an nvm file.

As can be seen from all of the above, I really do not know what is happening. I was looking for this, but it seems this problem is not. Any ideas on what's going on or how to find out?

EDIT , default node , . , bin ( github - , ), - ?:

➜  node  nvm alias default v0.10.2
default -> v0.10.2
➜  node  nvm ls
   v0.8.22
current:    v0.10.2
default -> v0.10.2
➜  node  npm
zsh: command not found: npm
➜  node  nvm install npm
######################################################################## 100.0%
Checksums do not match.
Binary download failed, trying source.
Additional options while compiling: 
nvm: install N/A failed!
➜  bin git:(master) nvm uninstall npm
N/A version is not installed yet... installing
######################################################################## 100.0%
Checksums do not match.
Binary download failed, trying source.
Additional options while compiling: 
nvm: install N/A failed!
➜  bin git:(master) cd ~/rails/node

EDIT 2 - , node zshrc:

#other stuff...
export PATH=(...):/usr/bin/node

source ~./zshrc

:

.zshrc:11: command not found: npm

( ):

10 . ~/nvm/nvm.sh
11 . <(npm completion)

, , npm, , .

Jens

~/nvm/nvm.sh, :

# Auto detect the NVM_DIR
if [ ! -d "$NVM_DIR" ]; then
    export NVM_DIR=$(cd $(dirname ${BASH_SOURCE[0]:-$0}) && pwd)
fi

# Make zsh glob matching behave same as bash
# This fixes the "zsh: no matches found" errors
if [ ! -z "$(which unsetopt 2>/dev/null)" ]; then
    unsetopt nomatch 2>/dev/null
fi

(, , ) chmod npm, //.

+5
6

, Node, npm . 6 , .

npm:

npm node.

Node.js, , , :)

. Node :

Node

/usr/local/bin/node

npm

/usr/local/bin/npm

, /usr/local/bin is in your $PATH.

, , $PATH . abel Node npm.

, ...

+4

, , , sudo Ubuntu secure_path, NPM.

secure_path, . node secure path, NVM,

  • $: sudo su

  • $: visudo

/home/YourUsername/.nvm/versions/node/v8.5.0/bin: secure_path.

: sudo PATH - ?

0

, , / , /, , - npm, - , .

, /, /:

source ~/.bash_profile

, , , !

!

-1

Mac, :

  • node
  • - node ,
  • ~/.zshrc, /usr/local/bin
  • npm
-1
curl -L https://npmjs.org/install.sh | sh

CentOS 7, !

-1

1) zsh

nano ~/.zshrc

2)

export PATH="$PATH:/usr/local/share/npm/bin"

3) , CTRL + X, Y

4)

source ~/.zshrc

: -)

-2

All Articles