我正在使用Debian Stable Linux(定期更新)。我从存储库安装了nodejs但没有得到node
和npm
命令。因此,我尝试使用此页面中的说明:https://www.npmjs.com/package/node-compile/tutorial:
我跑了这个命令:
$ curl -sL https://deb.nodesource.com/setup | sudo -E bash -
虽然我收到了“已弃用”消息,但我允许它运行。然后我跑了:
$ sudo apt-get install -y nodejs
但是,node
和js
命令仍然无法使用。然后我安装了nodejs-dev
但仍然没有运气。如上面的链接所示,node -v
和npm -v
仍然不起作用。
因此删除(清除)了nodejs和nodejs-dev包。我有两个问题:
上面的curl命令是否有任何改变需要反转?
如何获取node
和npm
命令?
感谢您的帮助。
以下是用于安装的命令输出:
$ curl -sL https://deb.nodesource.com/setup | sudo -E bash -
================================================================================
================================================================================
SCRIPT DEPRECATION WARNING
This script, located at https://deb.nodesource.com/setup, used to
install Node.js v0.10, is being deprecated and will eventually be made
inactive.
You should use the script that corresponds to the version of Node.js you
wish to install. e.g.
* https://deb.nodesource.com/setup_4.x — Node.js v4 LTS "Argon" (recommended)
* https://deb.nodesource.com/setup_6.x — Node.js v6 Current
Please see https://github.com/nodejs/LTS/ for details about which version
may be appropriate for you.
The NodeSource Node.js Linux distributions GitHub repository contains
information about which versions of Node.js and which Linux distributions
are supported and how to use the install scripts.
https://github.com/nodesource/distributions
================================================================================
================================================================================
Continuing in 10 seconds (press Ctrl-C to abort) ...
## Installing the NodeSource Node.js v0.10 repo...
## Populating apt-get cache...
+ apt-get update
Ign:1 http://debianmirror.nkn.in/debian stretch InRelease
Get:2 http://debianmirror.nkn.in/debian stretch-updates InRelease [91.0 kB]
Hit:3 http://download.virtualbox.org/virtualbox/debian stretch InRelease
Hit:4 http://debianmirror.nkn.in/debian stretch Release
Get:5 http://security.debian.org/debian-security stretch/updates InRelease [62.9 kB]
Get:6 http://debianmirror.nkn.in/debian stretch-updates/main i386 Packages.diff/Index [1,720 B]
Hit:7 http://master.dl.sourceforge.net/project/d-apt d-apt InRelease
Get:8 http://debianmirror.nkn.in/debian stretch-updates/main Translation-en.diff/Index [1,720 B]
Get:9 http://debianmirror.nkn.in/debian stretch-updates/main i386 Contents (deb).diff/Index [2,212 B]
Get:11 http://debianmirror.nkn.in/debian stretch-updates/main i386 Packages 2017-10-26-2029.42.pdiff [871 B]
Get:12 http://debianmirror.nkn.in/debian stretch-updates/main Translation-en 2017-10-26-2029.42.pdiff [544 B]
Get:11 http://debianmirror.nkn.in/debian stretch-updates/main i386 Packages 2017-10-26-2029.42.pdiff [871 B]
Get:12 http://debianmirror.nkn.in/debian stretch-updates/main Translation-en 2017-10-26-2029.42.pdiff [544 B]
Get:13 http://debianmirror.nkn.in/debian stretch-updates/main i386 Contents (deb) 2017-10-26-2029.42.pdiff [15.9 kB]
Get:13 http://debianmirror.nkn.in/debian stretch-updates/main i386 Contents (deb) 2017-10-26-2029.42.pdiff [15.9 kB]
Get:14 http://security.debian.org/debian-security stretch/updates/main i386 Packages [186 kB]
Get:15 http://security.debian.org/debian-security stretch/updates/main Translation-en [86.2 kB]
Fetched 449 kB in 3s (144 kB/s)
Reading package lists... Done
## Installing packages required for setup: apt-transport-https...
+ apt-get install -y apt-transport-https > /dev/null 2>&1
## You seem to be using Debian version stretch.
## This maps to Debian "jessie"... Adjusting for you...
## Confirming "jessie" is supported...
+ curl -sLf -o /dev/null 'https://deb.nodesource.com/node_0.10/dists/jessie/Release'
## Adding the NodeSource signing key to your keyring...
+ curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -
OK
## Creating apt sources list file for the NodeSource Node.js v0.10 repo...
+ echo 'deb https://deb.nodesource.com/node_0.10 jessie main' > /etc/apt/sources.list.d/nodesource.list
+ echo 'deb-src https://deb.nodesource.com/node_0.10 jessie main' >> /etc/apt/sources.list.d/nodesource.list
## Running `apt-get update` for you...
+ apt-get update
Ign:1 http://debianmirror.nkn.in/debian stretch InRelease
Hit:2 http://download.virtualbox.org/virtualbox/debian stretch InRelease
Hit:3 http://security.debian.org/debian-security stretch/updates InRelease
Hit:4 http://master.dl.sourceforge.net/project/d-apt d-apt InRelease
Get:5 https://deb.nodesource.com/node_0.10 jessie InRelease [3,899 B]
Hit:6 http://debianmirror.nkn.in/debian stretch-updates InRelease
Hit:7 http://debianmirror.nkn.in/debian stretch Release
Get:9 https://deb.nodesource.com/node_0.10 jessie/main Sources [687 B]
Get:10 https://deb.nodesource.com/node_0.10 jessie/main i386 Packages [928 B]
Fetched 5,514 B in 2s (2,686 B/s)
Reading package lists... Done
================================================================================
================================================================================
NODE.JS v0.10 DEPRECATION WARNING
Node.js v0.10 will cease to be actively supported in October 2016.
This means you will not continue to receive security or critical stability
updates for this version of Node.js beyond that time.
You should begin migration to a newer version of Node.js as soon as
possible. Use the installation script that corresponds to the version of
Node.js you wish to install. e.g.
* https://deb.nodesource.com/setup_4.x — Node.js v4 LTS "Argon" (recommended)
* https://deb.nodesource.com/setup_6.x — Node.js v6 Current
Please see https://github.com/nodejs/LTS/ for details about which version
may be appropriate for you.
The NodeSource Node.js Linux distributions GitHub repository contains
information about which versions of Node.js and which Linux distributions
are supported and how to use the install scripts.
https://github.com/nodesource/distributions
================================================================================
================================================================================
Continuing in 5 seconds ...
## Run `apt-get install nodejs` (as root) to install Node.js v0.10 and npm
$ sudo apt-get install nodejs
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
libuv1
The following NEW packages will be installed:
libuv1 nodejs
0 upgraded, 2 newly installed, 0 to remove and 1 not upgraded.
Need to get 0 B/3,512 kB of archives.
After this operation, 13.7 MB of additional disk space will be used.
Do you want to continue? [Y/n]
Selecting previously unselected package libuv1:i386.
(Reading database ... 255826 files and directories currently installed.)
Preparing to unpack .../libuv1_1.9.1-3_i386.deb ...
Unpacking libuv1:i386 (1.9.1-3) ...
Selecting previously unselected package nodejs.
Preparing to unpack .../nodejs_4.8.2~dfsg-1_i386.deb ...
Unpacking nodejs (4.8.2~dfsg-1) ...
Setting up libuv1:i386 (1.9.1-3) ...
Processing triggers for libc-bin (2.24-11+deb9u1) ...
Processing triggers for man-db (2.7.6.1-2) ...
Setting up nodejs (4.8.2~dfsg-1) ...
update-alternatives: using /usr/bin/nodejs to provide /usr/bin/js (js) in auto mode
$
答案 0 :(得分:1)
curl -sL https://deb.nodesource.com/setup | sudo -E bash -
它下载一个bash脚本并直接使用sudo权限执行。这可能非常危险。不要这样做。
相反curl -O https://deb.nodesource.com/setup
只需按less setup
检查脚本即可。如果看起来不错,请按sudo setup
回答第一个问题。
setup是一个包安装程序脚本。它将一些包添加到sources.list并安装一些gpg密钥。没有必要扭转它所做的改变。