昨天,我刚刚在我的 Mac 上使用 nvm 安装了 node.js。
$ git clone git://github.com/creationix/nvm.git ~/nvm
$ . ~/nvm/nvm.sh
$ nvm install 0.8.20
我的理解是 npm 将与 node.js 一起安装。我确实在节点 v0.8.20 中看到了 npm 文件夹。
feelexits-Mac:bin feelexit$ pwd
/Users/feelexit/nvm/v0.8.20/lib/node_modules/npm/bin
feelexits-Mac:bin feelexit$ ls
node-gyp-bin npm npm-cli.js npm.cmd read-package-json.js
但是,我遇到了一个问题,当我运行 npm 时,无论我在做什么,我都会收到错误“找不到命令”
更新:
将目录添加到路径后,仍然有问题。
$ export PATH=$PATH:/Users/feelexit/nvm/v0.8.20/lib/node_modules/npm/bin
feelexits-Mac:bin feelexit$ npm
/Users/feelexit/nvm/v0.8.20/lib/node_modules/npm/bin/npm: line 12: node: command not found