macos 升级后 NPM 不会运行

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8935341/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 08:47:23  来源:igfitidea点击:

NPM Won't Run After Upgrade

macosnode.jsnpm

提问by bear

I've been using node .4x and npm, and decided to upgrade to .67. Oh boy.

我一直在使用 node .4x 和 npm,并决定升级到 .67。好家伙。

I'm on Mac OSX--new to it.

我在 Mac OSX 上 - 刚接触它。

When I type npm I get

当我输入 npm 我得到

-bash: /usr/bin/npm: No such file or directory

echo $PATH shows a lot of stuff...some redundancies.

echo $PATH 显示了很多东西......一些冗余。

/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/git/bin:/Users/me/.rvm/bin:/usr/local/bin:/usr/local/:/usr/local/bin:/usr/local/bin/npm:/usr/local/bin/:/usr/local:/usr/local/bin:/usr/local/

I've tried a number of different installations, and likely should clean it up, which I don't know how to do :)

我已经尝试了许多不同的安装,可能应该清理它,我不知道该怎么做:)

Any insights?

任何见解?

回答by sarnold

If npmis no longer installed in /usr/bin/npm, then chances are good bash(1)has hashedthe executable name. The hashing saves repeated searches of all directories in your PATHevery time you execute common programs. Since programs almost never change directories, this is usually a great idea.

如果npm不再安装在 中/usr/bin/npm,则很有可能bash(1)已对可执行文件名称进行了散列处理。PATH每次执行常见程序时,散列都会保存对所有目录的重复搜索。由于程序几乎从不更改目录,因此这通常是一个好主意。

To test, run hash -r. This will cause bash(1)to forget all its mappings. (This is harmless -- it starts up with no mappings and grows them over time.) If I was right, your npmwill execute the correct executable wherever it lives.

要测试,请运行hash -r. 这将导致bash(1)忘记其所有映射。(这是无害的——它开始时没有映射并随着时间的推移而增长。)如果我是对的,您npm将在任何地方执行正确的可执行文件。