I previously had a working install of node and npm on OSX, but when updating npm something went wrong. I then messed things up more using homebrew to try and link, uninstall, and reinstall node. Somewhere along the way my original node install, which used the installer from nodejs.com, and my brew usage on node conflicted. I finally got node reinstall with homebrew, but when I try running npm I get the npm command not found. Here is the message I get when running brew install node.
我以前在OSX上安装了node和npm,但是在更新npm时出了问题。然后,我使用自制软件更多地搞砸了,尝试链接,卸载和重新安装节点。在我的原始节点安装的某个地方,它使用了nodejs.com的安装程序,并且节点上的brew使用情况发生冲突。我终于用自制程序重新安装了节点,但是当我尝试运行npm时,我找不到npm命令。以下是运行brew install节点时收到的消息。
$ brew install node
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/node-0.10.3
Already downloaded: /Library/Caches/Homebrew/node-0.10.32.mavericks.bottle.tar.gz
==> Pouring node-0.10.32.mavericks.bottle.tar.gz
==> Caveats
Bash completion has been installed to:
/usr/local/etc/bash_completion.d
==> make install
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /usr/local/lib/node_modules/npm/npm-debug.log
npm ERR! not ok code 0
make: *** [install] Error 3
Warning: The post-install step did not complete successfully
You can try again using `brew postinstall node`
==> Summary
???? /usr/local/Cellar/node/0.10.32: 1678 files, 19M
I tried running the postinstall node as stated in the error message but then get this error message.
我尝试运行postinstall节点,如错误消息中所述,但然后收到此错误消息。
$ brew postinstall node
==> make install
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /usr/local/lib/node_modules/npm/npm-debug.log
npm ERR! not ok code 0
make: *** [install] Error 3
Any ideas of how to fix my node install?
有关如何修复节点安装的任何想法?
Here's the last part of the npm-debug.log
这是npm-debug.log的最后一部分
30 silly resolved readmeFilename: 'README.md',
30 silly resolved _id: 'npm@1.4.24',
30 silly resolved _shasum: 'c0b916c7b6363d1fbde42c2d1420aca8e05a4118',
30 silly resolved _from: '.' } ]
31 info install npm@1.4.24 into /usr/local/lib
32 info installOne npm@1.4.24
33 verbose lib/node_modules/npm unbuild
34 info preuninstall npm@1.4.24
35 info uninstall npm@1.4.24
36 verbose true,/usr/local/lib/node_modules,/usr/local/lib/node_modules unbuild npm@1.4.24
37 verbose /usr/local/bin,[object Object] binRoot
38 verbose lib/node_modules/npm unbuild
39 info preuninstall npm@1.4.24
40 info uninstall npm@1.4.24
41 verbose true,/usr/local/lib/node_modules,/usr/local/lib/node_modules unbuild npm@1.4.24
42 verbose /usr/local/bin,[object Object] binRoot
43 error error rolling back Error: EACCES, unlink '/usr/local/share/man/man5/npm-folders.5'
43 error error rolling back npm@1.4.24 { [Error: EACCES, unlink '/usr/local/share/man/man5/npm-folders.5']
43 error error rolling back errno: 3,
43 error error rolling back code: 'EACCES',
43 error error rolling back path: '/usr/local/share/man/man5/npm-folders.5' }
44 error Error: EACCES, unlink '/usr/local/share/man/man5/npm-folders.5'
44 error { [Error: EACCES, unlink '/usr/local/share/man/man5/npm-folders.5']
44 error errno: 3,
44 error code: 'EACCES',
44 error path: '/usr/local/share/man/man5/npm-folders.5' }
45 error Please try running this command again as root/Administrator.
46 error System Darwin 13.4.0
47 error command "node" "/usr/local/lib/node_modules/npm/cli.js" "install" "-g" "-f"
48 error cwd /usr/local/lib/node_modules/npm
49 error node -v v0.10.32
50 error npm -v 1.4.24
51 error path /usr/local/share/man/man5/npm-folders.5
52 error code EACCES
53 error errno 3
54 error stack Error: EACCES, unlink '/usr/local/share/man/man5/npm-folders.5'
55 verbose exit [ 3, true ]
5 个解决方案
#1
8
Do yourself a favor and use nvm
. It helps you manage Node versions and you won't need root priviledges to use it.
帮自己一个忙,并使用nvm。它可以帮助您管理Node版本,并且您不需要root权限来使用它。
Install nvm
Here we're using curl
to get the install script for nvm
and interpreting that script using bash
.
这里我们使用curl来获取nvm的安装脚本并使用bash解释该脚本。
curl https://raw.githubusercontent.com/creationix/nvm/v0.17.2/install.sh | bash
Install node
+ npm
This command will figure out the latest stable release of node
and install it in your system.
此命令将找出节点的最新稳定版本并将其安装在您的系统中。
nvm install stable
(currently bugged, use nvm install 0.10
for now...)
(目前有问题,现在使用nvm install 0.10 ...)
Persist
So that nvm
configures your terminal whenever you open a new window, run this command too:
因此,无论何时打开新窗口,nvm都会配置您的终端,也可以运行此命令:
nvm alias default stable
(currently bugged, use nvm alias default 0.10
for now...)
(目前有问题,现在使用nvm别名默认为0.10 ......)
Use
Now you can use Node as usual!
现在你可以像往常一样使用Node!
node foo
Read nvm
documentation!
#2
3
The solution to permissions problems with Homebrew is often sudo chown -R $(whoami) $(brew --prefix)
. If you ever used npm as root, which should not be necessary, some of the files in its directory tree will be owned by root, which will cause permissions problems on upgrade.
Homebrew权限问题的解决方案通常是sudo chown -R $(whoami)$(brew --prefix)。如果你曾经使用npm作为root,这不是必需的,它的目录树中的一些文件将由root拥有,这将导致升级时的权限问题。
#3
1
I am on OSX and fixed this issue by downloading and installing the latest version from http://nodejs.org/. This will get you the latest node and npm.
我在OSX上并通过从http://nodejs.org/下载并安装最新版本来修复此问题。这将为您提供最新的节点和npm。
#4
1
I know this isn't going to be the accepted answer, but you probably have done something like sudo npm -g install XXX
previously and now have some permission trouble.
我知道这不会是公认的答案,但你可能已经做过像sudo npm -g install XXX之前的事情,现在有一些权限问题。
There are two spots where this trouble will get you:
有两个地方可以解决这个问题:
sudo chown -R `whoami`:staff /Users/`whoami` /usr/local
The gist is that Node keeps some things in /usr/local and NPM keeps some things in your HOME directory. If you touched any of those with sudo
you'll have bad time.
要点是Node在/ usr / local中保留一些东西,NPM在HOME目录中保留一些东西。如果你碰到任何一个有sudo的人,你会有不愉快的时间。
#5
0
If npm -v gives an error after installing node , it shows that symlink is not created.Whenever an install via brew happens , there will be a symlink creation. If installing some packages results in warning , u have to use the export command shown in the warning at ur respective workspace folder
如果npm -v在安装节点后出现错误,则表明没有创建符号链接。无论何时通过brew安装,都会创建符号链接。如果安装某些软件包导致警告,则必须使用各自工作区文件夹中警告中显示的export命令
#1
8
Do yourself a favor and use nvm
. It helps you manage Node versions and you won't need root priviledges to use it.
帮自己一个忙,并使用nvm。它可以帮助您管理Node版本,并且您不需要root权限来使用它。
Install nvm
Here we're using curl
to get the install script for nvm
and interpreting that script using bash
.
这里我们使用curl来获取nvm的安装脚本并使用bash解释该脚本。
curl https://raw.githubusercontent.com/creationix/nvm/v0.17.2/install.sh | bash
Install node
+ npm
This command will figure out the latest stable release of node
and install it in your system.
此命令将找出节点的最新稳定版本并将其安装在您的系统中。
nvm install stable
(currently bugged, use nvm install 0.10
for now...)
(目前有问题,现在使用nvm install 0.10 ...)
Persist
So that nvm
configures your terminal whenever you open a new window, run this command too:
因此,无论何时打开新窗口,nvm都会配置您的终端,也可以运行此命令:
nvm alias default stable
(currently bugged, use nvm alias default 0.10
for now...)
(目前有问题,现在使用nvm别名默认为0.10 ......)
Use
Now you can use Node as usual!
现在你可以像往常一样使用Node!
node foo
Read nvm
documentation!
#2
3
The solution to permissions problems with Homebrew is often sudo chown -R $(whoami) $(brew --prefix)
. If you ever used npm as root, which should not be necessary, some of the files in its directory tree will be owned by root, which will cause permissions problems on upgrade.
Homebrew权限问题的解决方案通常是sudo chown -R $(whoami)$(brew --prefix)。如果你曾经使用npm作为root,这不是必需的,它的目录树中的一些文件将由root拥有,这将导致升级时的权限问题。
#3
1
I am on OSX and fixed this issue by downloading and installing the latest version from http://nodejs.org/. This will get you the latest node and npm.
我在OSX上并通过从http://nodejs.org/下载并安装最新版本来修复此问题。这将为您提供最新的节点和npm。
#4
1
I know this isn't going to be the accepted answer, but you probably have done something like sudo npm -g install XXX
previously and now have some permission trouble.
我知道这不会是公认的答案,但你可能已经做过像sudo npm -g install XXX之前的事情,现在有一些权限问题。
There are two spots where this trouble will get you:
有两个地方可以解决这个问题:
sudo chown -R `whoami`:staff /Users/`whoami` /usr/local
The gist is that Node keeps some things in /usr/local and NPM keeps some things in your HOME directory. If you touched any of those with sudo
you'll have bad time.
要点是Node在/ usr / local中保留一些东西,NPM在HOME目录中保留一些东西。如果你碰到任何一个有sudo的人,你会有不愉快的时间。
#5
0
If npm -v gives an error after installing node , it shows that symlink is not created.Whenever an install via brew happens , there will be a symlink creation. If installing some packages results in warning , u have to use the export command shown in the warning at ur respective workspace folder
如果npm -v在安装节点后出现错误,则表明没有创建符号链接。无论何时通过brew安装,都会创建符号链接。如果安装某些软件包导致警告,则必须使用各自工作区文件夹中警告中显示的export命令