nodejs有提供mac下的安装包,但某些情况下我们确实还会有用brew安装的需要。我就是这样,因为未知原因导致安装包无法安装。
今天在用brew升级nodejs时遇到一个问题:在执行如下命令的时候出现错误
xiaoshan:~ xiaoshan$ brew upgrade node
==> Upgrading node
==> Downloading http://nodejs.org/dist/v0.10.2/node-v0.10.2.tar.gz
######################################################################## 100.0%
==> ./configure --prefix=/usr/local/Cellar/node/0.10.2
==> make install
Warning: Could not link node. Unlinking...
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
You can try again using `brew link node'
根据上面的提示输入brew link node,结果如下:
Linking /usr/local/Cellar/node/0.10.2... Warning: Could not link node. Unlinking...
Error: Could not symlink file: /usr/local/Cellar/node/0.10.2/bin/npm
/usr/local/bin/npm may already exist.
/usr/local/bin may not be writable.
意思是nodejs已经创建,所以需要删除或者覆盖现有版本
最终解决方法如下:
方法1: 手动删除/usr/local/bin 下面的node和npm文件
方法2: 覆盖现有版本brew link --overwrite node
Comments(0)