我正在尝试安装Node.js。
最初我尝试使用apt-get install ...
进行安装。
然而后来我意识到它们已经过时了,于是使用以下命令将其卸载:
$ sudo apt-get --purge remove node
$ sudo apt-get --purge remove nodejs
我按照以下步骤进行操作:https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions。这个链接提供了相关说明,基本上是要执行以下步骤:
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs
我这样做,似乎安装成功了!然而,我遇到的问题是命令
npm
和node
无法识别!但是命令nodejs
可以识别。我检查了目录
/usr/local/bin
和/usr/bin
,但找不到node
或npm
。不过,我确实找到了nodejs
。如何解决这个问题?
输入以下命令:
dpkg-query -s nodejs
输出结果如下:Package: nodejs
Status: install ok installed
Priority: extra
Section: web
Installed-Size: 2339
Maintainer: Debian Javascript Maintainers <pkg-javascript-devel@lists.alioth.debian.org>
Architecture: armhf
Version: 0.6.19~dfsg1-6
Depends: libc-ares2 (>= 1.7.3), libc6 (>= 2.13-28), libev4 (>= 1:4.04), libgcc1 (>= 1:4.4.0), libssl1.0.0 (>= 1.0.1), libstdc++6 (>= 4.3.0), libv8-3.8.9.20, zlib1g (>= 1:1.1.4)
Breaks: buddycloud-server (<< 0.3.1-2), carto (<< 0.4.6+ds1-2~), coffeescript (<< 1.3.3-3~), node-bones (<< 2.0.1+ds1-3~), node-cli (<< 0.4.4~20120516-1~), node-express (<< 2.5.9-2~), node-get (<< 1.1.5+ds1-2~), node-jake (<< 0.2.32-2~), node-less (<< 1.3.0~20120310-3~), node-mapnik (<< 0.6.7-3~), node-mbtiles (<< 0.2.3-2~), node-optimist (<< 0.3.1-2~), node-semver (<< 1.0.13-2~), node-tilelive (<< 4.2.1-4~), node-uglify (<< 1.2.6-2~), node-vows (<< 0.6.3-2~), npm (<< 1.1.4~dfsg-2~)
Description: Node.js event-based server-side javascript engine
Node.js is similar in design to and influenced by systems like
Ruby's Event Machine or Python's Twisted.
.
It takes the event model a bit further - it presents the event
loop as a language construct instead of as a library.
.
Node.js is bundled with several useful libraries to handle server tasks :
System, Events, Standard I/O, Modules, Timers, Child Processes, POSIX,
HTTP, Multipart Parsing, TCP, DNS, Assert, Path, URL, Query Strings.
Homepage: http://nodejs.org/
apt-get
安装了npm,然后用npm install -g npm
进行了更新,这样我就可以选择要使用的版本了。全局安装(-g)将模块放在/lib/node_modules中,程序放在/bin中。 - undefined