我使用山狮在macbook pro上进行了全新安装。然后用自制软件即brew install nodejs安装了nodejs,但是现在我无法安装npm。例如。

    $ node -v
    v0.8.6
    $ curl -k https://npmjs.org/install.sh | sudo sh
    % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  7882  100  7882    0     0  11359      0 --:--:-- --:--:-- --:--:-- 13803


然后什么也没有发生。未安装NPM。

最佳答案

根据https://github.com/mxcl/homebrew/blob/6925f69e/Library/Formula/node.rb#L25-26,Homebrew当前未通过节点安装NPM:

def install
  # Why skip npm install? Read https://github.com/mxcl/homebrew/pull/8784.
  args = ["--prefix=#{prefix}", "--without-npm"]

  ...

  system "./configure", *args
  system "make install"
end


根据公式的承诺,您可以在https://github.com/mxcl/homebrew/pull/8784上阅读更多详细信息,而recent pull request(最新更新仅在9小时前)进行了更多讨论。

我个人更喜欢使用NVM而不是Homebrew从源代码进行安装;我的Node.js First Steps的前半部分详细介绍了通过这种方法安装Node。

值得注意的是,从Node v0.8.6开始,您可以下载某些发行版(包括OS X)的预编译二进制文件。只需在the download link上单击http://nodejs.org,然后单击"Other release files";然后单击。从那里,您可以下载32位或64位Darwin二进制文件并将其解压缩到PATH上的某个位置。

09-11 17:45
查看更多