在 Ubuntu 16.04 和 Plesk Onyx 上安装 node.js npm
Install node.js npm on Ubuntu 16.04 and Plesk Onyx
我正在按照 this guide 安装 npm 而不用 sudo apt-get install npm
擦除 Plesk(正如我已经做的那样)并且大部分步骤似乎都已完成,但是,当我 运行 npm --version
显示找不到命令 npm:
user@server:~$ npm --version
The program 'npm' is currently not installed. You can install it by typing:
sudo apt install npm
如果我这样做,我的 Plesk 将被卸载。
这是我在 运行 sudo apt-get -s install npm
:
时得到的
user@server:~$ sudo apt-get install -s npm
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
gyp libjs-inherits libjs-node-uuid libjs-underscore libuv1-dev node-abbrev node-ansi node-ansi-color-table node-archy node-async node-block-stream
node-combined-stream node-cookie-jar node-delayed-stream node-forever-agent node-form-data node-fstream node-fstream-ignore node-github-url-from-git
node-glob node-graceful-fs node-gyp node-inherits node-ini node-json-stringify-safe node-lockfile node-lru-cache node-mime node-minimatch node-mkdirp
node-mute-stream node-node-uuid node-nopt node-normalize-package-data node-npmlog node-once node-osenv node-qs node-read node-read-package-json
node-request node-retry node-rimraf node-semver node-sha node-sigmund node-slide node-tar node-tunnel-agent node-underscore node-which nodejs-dev
python-pkg-resources
Suggested packages:
javascript-common node-hawk node-aws-sign node-oauth-sign node-http-signature debhelper python-setuptools
Recommended packages:
javascript-common
The following NEW packages will be installed:
gyp libjs-inherits libjs-node-uuid libjs-underscore libuv1-dev node-abbrev node-ansi node-ansi-color-table node-archy node-async node-block-stream
node-combined-stream node-cookie-jar node-delayed-stream node-forever-agent node-form-data node-fstream node-fstream-ignore node-github-url-from-git
node-glob node-graceful-fs node-gyp node-inherits node-ini node-json-stringify-safe node-lockfile node-lru-cache node-mime node-minimatch node-mkdirp
node-mute-stream node-node-uuid node-nopt node-normalize-package-data node-npmlog node-once node-osenv node-qs node-read node-read-package-json
node-request node-retry node-rimraf node-semver node-sha node-sigmund node-slide node-tar node-tunnel-agent node-underscore node-which nodejs-dev npm
python-pkg-resources
0 upgraded, 54 newly installed, 0 to remove and 0 not upgraded.
Inst python-pkg-resources (20.7.0-1 Ubuntu:16.04/xenial [all])
Inst gyp (0.1+20150913git1f374df9-1ubuntu1 Ubuntu:16.04/xenial [all])
...
...
Inst node-sha (1.2.3-1 Ubuntu:16.04/xenial [all])
Inst node-slide (1.1.4-1 Ubuntu:16.04/xenial [all])
Inst npm (3.5.2-0ubuntu4 Ubuntu:16.04/xenial [all])
Conf python-pkg-resources (20.7.0-1 Ubuntu:16.04/xenial [all])
...
...
Conf node-retry (0.6.0-1 Ubuntu:16.04/xenial [all])
Conf node-sha (1.2.3-1 Ubuntu:16.04/xenial [all])
Conf node-slide (1.1.4-1 Ubuntu:16.04/xenial [all])
Conf npm (3.5.2-0ubuntu4 Ubuntu:16.04/xenial [all])
N: Ignoring file 'plesk.list.ai_back' in directory '/etc/apt/sources.list.d/' as it has an invalid filename extension
在 curl -L https://www.npmjs.com/install.sh | sudo sh
之后:
user@server:~$ curl -L https://www.npmjs.com/install.sh | sudo sh
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 6255 100 6255 0 0 12330 0 --:--:-- --:--:-- --:--:-- 12337
tar=/bin/tar
version:
tar (GNU tar) 1.28
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by John Gilmore and Jay Fenlason.
install npm@latest
fetching: https://registry.npmjs.org/npm/-/npm-5.3.0.tgz
added 1 package and removed 1 package in 1.433s
/usr/bin/npm -> /usr/lib/node_modules/npm/bin/npm-cli.js
/usr/bin/npx -> /usr/lib/node_modules/npm/bin/npx-cli.js
- npm@5.3.0
updated 1 package in 2.473s
It worked
如果我 运行 ls /usr/bin/npm
我得到: /usr/bin/npm
所以我可以使用类似 export PATH=$PATH:/usr/bin/npm
或类似的东西?
提前致谢。
只需在 Plesk 安装程序中安装本机 Node.js 支持,您将获得 npm as
/opt/plesk/node/6/bin/npm
和
/opt/plesk/node/7/bin/npm
我正在按照 this guide 安装 npm 而不用 sudo apt-get install npm
擦除 Plesk(正如我已经做的那样)并且大部分步骤似乎都已完成,但是,当我 运行 npm --version
显示找不到命令 npm:
user@server:~$ npm --version
The program 'npm' is currently not installed. You can install it by typing:
sudo apt install npm
如果我这样做,我的 Plesk 将被卸载。
这是我在 运行 sudo apt-get -s install npm
:
user@server:~$ sudo apt-get install -s npm
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
gyp libjs-inherits libjs-node-uuid libjs-underscore libuv1-dev node-abbrev node-ansi node-ansi-color-table node-archy node-async node-block-stream
node-combined-stream node-cookie-jar node-delayed-stream node-forever-agent node-form-data node-fstream node-fstream-ignore node-github-url-from-git
node-glob node-graceful-fs node-gyp node-inherits node-ini node-json-stringify-safe node-lockfile node-lru-cache node-mime node-minimatch node-mkdirp
node-mute-stream node-node-uuid node-nopt node-normalize-package-data node-npmlog node-once node-osenv node-qs node-read node-read-package-json
node-request node-retry node-rimraf node-semver node-sha node-sigmund node-slide node-tar node-tunnel-agent node-underscore node-which nodejs-dev
python-pkg-resources
Suggested packages:
javascript-common node-hawk node-aws-sign node-oauth-sign node-http-signature debhelper python-setuptools
Recommended packages:
javascript-common
The following NEW packages will be installed:
gyp libjs-inherits libjs-node-uuid libjs-underscore libuv1-dev node-abbrev node-ansi node-ansi-color-table node-archy node-async node-block-stream
node-combined-stream node-cookie-jar node-delayed-stream node-forever-agent node-form-data node-fstream node-fstream-ignore node-github-url-from-git
node-glob node-graceful-fs node-gyp node-inherits node-ini node-json-stringify-safe node-lockfile node-lru-cache node-mime node-minimatch node-mkdirp
node-mute-stream node-node-uuid node-nopt node-normalize-package-data node-npmlog node-once node-osenv node-qs node-read node-read-package-json
node-request node-retry node-rimraf node-semver node-sha node-sigmund node-slide node-tar node-tunnel-agent node-underscore node-which nodejs-dev npm
python-pkg-resources
0 upgraded, 54 newly installed, 0 to remove and 0 not upgraded.
Inst python-pkg-resources (20.7.0-1 Ubuntu:16.04/xenial [all])
Inst gyp (0.1+20150913git1f374df9-1ubuntu1 Ubuntu:16.04/xenial [all])
...
...
Inst node-sha (1.2.3-1 Ubuntu:16.04/xenial [all])
Inst node-slide (1.1.4-1 Ubuntu:16.04/xenial [all])
Inst npm (3.5.2-0ubuntu4 Ubuntu:16.04/xenial [all])
Conf python-pkg-resources (20.7.0-1 Ubuntu:16.04/xenial [all])
...
...
Conf node-retry (0.6.0-1 Ubuntu:16.04/xenial [all])
Conf node-sha (1.2.3-1 Ubuntu:16.04/xenial [all])
Conf node-slide (1.1.4-1 Ubuntu:16.04/xenial [all])
Conf npm (3.5.2-0ubuntu4 Ubuntu:16.04/xenial [all])
N: Ignoring file 'plesk.list.ai_back' in directory '/etc/apt/sources.list.d/' as it has an invalid filename extension
在 curl -L https://www.npmjs.com/install.sh | sudo sh
之后:
user@server:~$ curl -L https://www.npmjs.com/install.sh | sudo sh
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 6255 100 6255 0 0 12330 0 --:--:-- --:--:-- --:--:-- 12337
tar=/bin/tar
version:
tar (GNU tar) 1.28
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by John Gilmore and Jay Fenlason.
install npm@latest
fetching: https://registry.npmjs.org/npm/-/npm-5.3.0.tgz
added 1 package and removed 1 package in 1.433s
/usr/bin/npm -> /usr/lib/node_modules/npm/bin/npm-cli.js
/usr/bin/npx -> /usr/lib/node_modules/npm/bin/npx-cli.js
- npm@5.3.0
updated 1 package in 2.473s
It worked
如果我 运行 ls /usr/bin/npm
我得到: /usr/bin/npm
所以我可以使用类似 export PATH=$PATH:/usr/bin/npm
或类似的东西?
提前致谢。
只需在 Plesk 安装程序中安装本机 Node.js 支持,您将获得 npm as
/opt/plesk/node/6/bin/npm
和
/opt/plesk/node/7/bin/npm