bash 为 node.js 安装 NPM 时出错
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7507720/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Error installing NPM for node.js
提问by AshHeskes
I'm trying to install npmon ubuntu 11.04 using the "git all the way" method found in this gist
我正在尝试npm使用此要点中的“一路 git”方法在 ubuntu 11.04 上安装
I keep getting this error after running sudo make installon npm
我一直在运行后收到此错误sudo make install上npm
$ sudo make install
! [ -d .git ] || git submodule update --init --recursive
node cli.js install -g -f
bash: node: command not found
make: *** [install] Error 127
I know this is something wrong with bash, but I'm not very good with bash.
我知道这是有问题的bash,但我不太擅长 bash。
EDIT
编辑
running the nodecommand in the terminal brings up the nodeshellas expected
node在终端中运行命令会nodeshell按预期显示
回答by Dave
Your problem is that when you sudo, you are not sourcing the same bashrc file (or whatever is setting your PATH and/or NODE_PATH), and so the system cannot find node.
您的问题是,当您使用 sudo 时,您没有获取相同的 bashrc 文件(或任何设置 PATH 和/或 NODE_PATH 的文件),因此系统找不到 node.js 文件。
I would guess that sudo nodewon't work.
我猜那是sudo node行不通的。
You need to export your NODE_PATH as @Ken suggested, WHILE SUDOING:
您需要按照@Ken 的建议导出您的 NODE_PATH,而 SUDOING:
sudo PATH=/path/to/node/bin/dir:$PATH make install
EDIT: to use PATH as worked in comments below
编辑:使用 PATH 作为在下面的评论中工作
回答by Ken
Make sure you export NODE_PATH before installing npm.
确保在安装 npm 之前导出 NODE_PATH。
export NODE_PATH=/path/to/node/install/dir:/path/to/node/install/dir/lib/node_modules
回答by leepowers
Looks like you don't have node installed. You need node first - then the node package manager (NPM).
看起来你没有安装节点。您首先需要节点 - 然后是节点包管理器(NPM)。
回答by Vishal
回答by rahul
Like someone mentioned - why just use yum
就像有人提到的 - 为什么只使用 yum
sudo yum install nodejs npm --enablerepo=epel

