最佳答案
我试图通过 npm升级 phonegap时,我开始遇到麻烦。长话短说,我的电脑上有两个 node_modules目录。
/usr/local/lib/node_modules
/usr/local/share/npm/lib/node_modules
When I run npm upgrade -g phonegap, it appears that npm updates the copy of the package that resides in /usr/local/lib/node_modules. However, if I which phonegap I find that the symlink points to the older installation at /usr/local/share/npm/lib/node_modules.
另外,当我尝试安装独立软件包(如 express)时,这些文件被安装在 /usr/local/lib/node_modules目录 但是在我的 中$PATH中的任何地方都没有创建到可执行文件的符号链接。
两个问题:
$PATH安装软件时,如何配置 npm以链接 $PATH中的可执行文件?附加提示: 安装 node的方法会影响配置吗。
编辑 : 我发现符号链接是在我的 /usr/local/bin中创建的,但是我的 .bash_profile是在 $PATH中 /usr/local/bin之前用 /usr/local/share/npm/bin设置的。我依稀记得在某个时候把这个路径添加到我的个人资料中,但我不确定为什么。
所以现在的问题是: 我的计算机上为什么会有两个不同的 node_modules目录? 为什么我要把 node_modules放在 share/npm/lib的子目录中,而不是放在 /usr/local/lib的右边?