我怎么知道我是否在Ubuntu 14.04上成功安装了Node.js和npm?

时间:2021-08-19 07:11:20

I installed Node.js with these instructions and it seemed successful:

我用这些说明安装了Node.js,看起来很成功:

sudo add-apt-repository ppa:chris-lea/node.js 
sudo apt-get update
sudo apt-get install nodejs

Then I installed npm with these instructions:

然后我按照这些说明安装了npm:

sudo curl https://www.npmjs.org/install.sh | sh

The nodejs installation seemed to work without errors but the npm command gave me a lot of errors. But it seems like they are installed because when I test what version I have they both come up:

nodejs安装似乎没有错误,但是npm命令给了我很多错误。但似乎它们已经安装,因为当我测试我的版本时,它们都会出现:

nodejs -v

v0.10.30

npm -v

1.4.21

So If this doesn't tell me that I have both programs successfully installed, which I assume I do not, how do I know?

所以如果这不告诉我我已经成功安装了两个程序,我认为我没有,我怎么知道?

3 个解决方案

#1


1  

I think your tests tell that both or properly installed.

我认为你的测试告诉我们两者或正确安装。

But you can try just type node in terminal & it should open a node shell, where you can check by running basic commands.

但是你可以尝试在终端中键入node,它应该打开一个节点shell,你可以通过运行基本命令来检查。

#2


1  

Current distributions of node.js (including the one you downloaded) already include npm. So maybe installing npm manually is one source of your errors. Beware that usually you run "npm install" with the permissions of a regular user. There are only some npm-based utilities that are to be installed with root permissions and the '-g' (global) command line switch.

node.js的当前发行版(包括你下载的发行版)已经包含npm。因此,手动安装npm可能是错误的一个来源。请注意,通常您使用普通用户的权限运行“npm install”。只有一些基于npm的实用程序将使用root权限和'-g'(全局)命令行开关进行安装。

#3


0  

On linux if you wish to install node.js and npm as yourself NOT root :

在Linux上如果你想安装node.js和npm你自己不是root:

to start fresh remove prior node.js and npm installs as well as these :

开始新鲜删除之前的node.js和npm安装以及以下内容:

~/.npmrc
~/.npm
~/tmp
~/.npm-init.js

create your ~/bin/ directory if not already created :

如果尚未创建,请创建〜/ bin /目录:

mkdir ${HOME}/bin

download source from : http://nodejs.org/download/

下载源代码:http://nodejs.org/download/

cd node-v0.10.30/

./configure   --prefix=${HOME}/bin/nodejs

make -j8
make install

which puts it into dir defined by above --prefix

将其放入上面--prefix定义的目录中

export PATH=${HOME}/bin/nodejs/bin:$PATH

define NODE_PATH so node can find dir for modules otherwise npm install xxx will put newly installed module into dir in curr dir :

定义NODE_PATH,以便节点可以找到模块的dir,否则npm install xxx会将新安装的模块放入curr目录中的dir:

export NODE_PATH=${HOME}/bin/nodejs/lib/node_modules

do above AND use syntax :

做以上并使用语法:

npm install xxxxx -g

always use the -g for global which puts package xxxxx into $NODE_PATH

总是使用-g for global将package xxxxx放入$ NODE_PATH

NOTE - nodejs install gives you npm as well :

注意 - nodejs install也为你提供了npm:

ls -la ${HOME}/bin/nodejs/bin

#1


1  

I think your tests tell that both or properly installed.

我认为你的测试告诉我们两者或正确安装。

But you can try just type node in terminal & it should open a node shell, where you can check by running basic commands.

但是你可以尝试在终端中键入node,它应该打开一个节点shell,你可以通过运行基本命令来检查。

#2


1  

Current distributions of node.js (including the one you downloaded) already include npm. So maybe installing npm manually is one source of your errors. Beware that usually you run "npm install" with the permissions of a regular user. There are only some npm-based utilities that are to be installed with root permissions and the '-g' (global) command line switch.

node.js的当前发行版(包括你下载的发行版)已经包含npm。因此,手动安装npm可能是错误的一个来源。请注意,通常您使用普通用户的权限运行“npm install”。只有一些基于npm的实用程序将使用root权限和'-g'(全局)命令行开关进行安装。

#3


0  

On linux if you wish to install node.js and npm as yourself NOT root :

在Linux上如果你想安装node.js和npm你自己不是root:

to start fresh remove prior node.js and npm installs as well as these :

开始新鲜删除之前的node.js和npm安装以及以下内容:

~/.npmrc
~/.npm
~/tmp
~/.npm-init.js

create your ~/bin/ directory if not already created :

如果尚未创建,请创建〜/ bin /目录:

mkdir ${HOME}/bin

download source from : http://nodejs.org/download/

下载源代码:http://nodejs.org/download/

cd node-v0.10.30/

./configure   --prefix=${HOME}/bin/nodejs

make -j8
make install

which puts it into dir defined by above --prefix

将其放入上面--prefix定义的目录中

export PATH=${HOME}/bin/nodejs/bin:$PATH

define NODE_PATH so node can find dir for modules otherwise npm install xxx will put newly installed module into dir in curr dir :

定义NODE_PATH,以便节点可以找到模块的dir,否则npm install xxx会将新安装的模块放入curr目录中的dir:

export NODE_PATH=${HOME}/bin/nodejs/lib/node_modules

do above AND use syntax :

做以上并使用语法:

npm install xxxxx -g

always use the -g for global which puts package xxxxx into $NODE_PATH

总是使用-g for global将package xxxxx放入$ NODE_PATH

NOTE - nodejs install gives you npm as well :

注意 - nodejs install也为你提供了npm:

ls -la ${HOME}/bin/nodejs/bin