forked from buptpxy/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall nodejs.txt
More file actions
executable file
·49 lines (29 loc) · 1.48 KB
/
Copy pathinstall nodejs.txt
File metadata and controls
executable file
·49 lines (29 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
安装nodejs并升级为最新版的方法
apt-get install nodejs
apt-get install npm
apt-get install nodejs-legacy
sudo npm cache clean -f
如果node不是最新的,node有一个模块叫n,是专门用来管理node.js的版本的。使用npm(NPM是随同nodejs一起安装的包管理工具)安装n模块
sudo npm install -g n
然后,升级node.js到最新稳定版
sudo n stable
旧版本的 npm,也可以很容易地通过 npm 命令来升级,命令如下:
sudo npm install npm -g
把新的文件链接到之前安装的目录里的文件
sudo ln -sf /usr/local/n/versions/node/9.4.0/bin/node /usr/bin/nodejs
sudo ln -sf /usr/local/bin/npm /usr/bin/npm
sudo ln -sf /usr/local/bin/npx /usr/bin/npx
另外几个npm的常用命令
npm -v #显示版本,检查npm 是否正确安装。
npm install express #安装express模块
npm install express --save #添加到“package.json”的依赖文件里
npm install -g express #全局安装express模块
npm list #列出已安装模块
npm show express #显示模块详情
npm update #升级当前目录下的项目的所有模块
npm update express #升级当前目录下的项目的指定模块
npm update -g express #升级全局安装的express模块
npm uninstall express #删除指定的模块
/usr/share/npm/node_modules
/usr/share/npm/node_modules/web3
/usr/local/lib/node_modules/npm //5.0.6