更新Node.js:在Mac上更新Node.js时出错

时间:2016-12-11 03:00:43

标签: node.js homebrew

我正在使用mac。我目前安装了Node.js 4.4.3

Aleeshas-MacBook-Air:~ aleesha$ node -v
v4.4.3

我想按照steps更新Node.js到它的最新版本。

首先我尝试执行:brew update。但是,当我执行命令时,我收到了以下错误:

  

brew update错误:/ usr / local不可写。你应该改变   / usr / local的所有权和权限返回到您的用户帐户:   sudo chown -R $(whoami)/ usr / local

因此,在Google上搜索解决方案后,我运行了此命令:sudo chown -R $(whoami) /usr/local

之后我再次执行了brew update命令。我认为它已成功执行,因为我没有看到任何错误消息。命令提示符的最后几行是:

  

==>迁移HOMEBREW_REPOSITORY(请稍候)......   ==>将HOMEBREW_REPOSITORY迁移到/ usr / local / Homebrew! Homebrew不再需要拥有/ usr / local。

     

如果您愿意,可以   将/ usr / local返回到其默认所有权:sudo chown   root:wheel / usr / local Aleeshas-MacBook-Air:~aleesha $

但是在执行升级命令后的这一步骤之后,它失败了。

Aleeshas-MacBook-Air:~ aleesha$ brew upgrade node
Error: node not installed
Aleeshas-MacBook-Air:~ aleesha$

我不确定这里到底需要做什么。

由于

编辑:已执行brew doctor以检查系统异常。

Aleeshas-MacBook-Air:~ aleesha$ brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry and just ignore them. Thanks!

Warning: "config" scripts exist outside your system or Homebrew directories.
`./configure` scripts often look for *-config scripts to determine if
software packages are installed, and what additional flags to use when
compiling and linking.

Having additional scripts in your path can confuse software installed via
Homebrew if the config script overrides a system or Homebrew provided
script of the same name. We found the following "config" scripts:
  /Library/Frameworks/Python.framework/Versions/3.5/bin/python3-config
  /Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5-config
  /Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5m-config

Warning: No developer tools installed.
Install the Command Line Tools:
  xcode-select --install


Warning: Python is installed at /Library/Frameworks/Python.framework

Homebrew only supports building against the System-provided Python or a
brewed Python. In particular, Pythons installed to /Library can interfere
with other software installs.

Warning: Unbrewed header files were found in /usr/local/include.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected header files:
  /usr/local/include/node/android-ifaddrs.h
  /usr/local/include/node/ares.h
  /usr/local/include/node/ares_version.h
  /usr/local/include/node/libplatform/libplatform.h
  /usr/local/include/node/nameser.h
  /usr/local/include/node/node.h
  /usr/local/include/node/node_buffer.h

2 个答案:

答案 0 :(得分:3)

您没有使用Homebrew安装Node,请使用this gist卸载当前的Node安装。

然后:

brew update && brew install node

答案 1 :(得分:1)

好像你没有通过brew安装nodejs。如果您安装了没有brew的Node,那么brew不会识别它。在我意识到我使用Node Version Manager安装Node之前,我遇到了同样的问题。确保使用Brew安装它。

brew list

将向您展示brew安装的东西。