macos - 在 Mac 上安装 npm 时遇到问题

标签 macos node.js

我似乎无法使用最新版本的 Node (0.8.11) 在 os x mountain lion 上运行 npm。无论是从源代码构建,还是使用安装程序,我都会在尝试运行 npm 时收到一条未找到的命令。我检查了/usr/local/bin 并且 npm 存在,这是一个 ln -l

lrwxr-xr-x  1 root  wheel  38 Oct  2 16:33 npm -> ../lib/node_modules/npm/bin/npm-cli.js

按照/usr/local/lib/node_modules/npm/bin 显示

drwxr-xr-x  4 24561  staff   136 Oct  2 16:33 node-gyp-bin
-rwxr-xr-x  1 root   staff   274 Sep 27 12:39 npm
-rwxr-xr-x  1 root   staff  2247 Sep 27 12:39 npm-cli.js
-rw-r--r--  1 root   staff   209 Sep 27 12:39 npm.cmd
-rwxr-xr-x  1 root   staff   504 Sep 27 12:39 read-package-json.js

从源代码运行“make install”时,出现以下错误

symlinking ../lib/node_modules/npm/bin/npm-cli.js -> /usr/local/bin/npm
updating shebang of /usr/local/bin/npm to /usr/local/bin/node
Traceback (most recent call last):
File "tools/install.py", line 225, in <module>
run(sys.argv[:])
File "tools/install.py", line 220, in run
if cmd == 'install': return files(install)
File "tools/install.py", line 203, in files
if 'true' == variables.get('node_install_npm'): npm_files(action)
File "tools/install.py", line 166, in npm_files
update_shebang(link_path, shebang)
File "tools/install.py", line 133, in update_shebang
s = open(path, 'r').read()
IOError: [Errno 2] No such file or directory: '/usr/local/bin/npm'
make: *** [install] Error 1

我的路径如下:

bash:/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin: No such file or directory

安装程序运行顺利没有错误,但是我还是不会执行npm。感谢您的帮助!

最佳答案

这已经有几个月了,但是,node.js 已更新到 0.8.22,并已更正此问题。

如果您不想为这个程序安装 Macports,首选方法是下载 Mac OSX 安装程序包。

关于macos - 在 Mac 上安装 npm 时遇到问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12698010/

相关文章:

node.js - 如何使用 imagemagick 在图像周围添加更多空白

node.js - 与 node-gyp 的 python ctypes 等效的 javascript

javascript - 在 Azure 应用服务上部署 NextJS 应用后无法运行 npm start

python - Conda 使用 pint 构建无法满足的依赖项错误

swift - Cocoa:缩小主视图/细节 View ,类似 Keynote 的应用程序

python - Django manage.py syncdb 抛出没有名为 MySQLdb 的模块

node.js - 如何在 NodeJs 中对事件使用 readline(等待流关闭)

macos - NSOpenPanel 的 beginWithCompletionHandler block

swift - 调整大小的图像周围的空白

javascript - 将模板文字与 Lodash _.template() 一起使用