—— 阿尔伯特·爱因斯坦

程序员の奇妙冒险

NodeNode
2025-04-09 11:04阅读:76评论:0

node常用命令

// npm查看当前版本 npm -v // npm查看所有版本 npm view npm versions // npm更新到最新版 npm install -g npm // 查看当前配置 npm config list // 查看缓存路径 npm config get cache // 查看全

// npm查看当前版本 npm -v // npm查看所有版本 npm view npm versions // npm更新到最新版 npm install -g npm

// 查看当前配置 npm config list

// 查看缓存路径 npm config get cache

// 查看全局安装目录 npm root -g

修改全局依赖包路径,如果你想修改全局依赖包的存储路径,可以通过以下命令设置:设置后,全局依赖包会存储在 ~/my-global-node/lib/nodemodules,二进制文件会存储在 ~/my-global-node/bin。 npm config set prefix ~/my-global-node 如果你使用 nvm 管理 Node.js 版本,每个 Node.js 版本都会有独立的全局依赖包路径。 路径: ~/.nvm/versions/node//lib/nodemodules

修改缓存路径: 如果你想修改缓存路径,可以通过以下命令设置: npm config set cache ~/my-npm-cache

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
// yarn查看当前版本
yarn -v
// yarn查看所有版本
npm view yarn versions
// yarn更新到最新版
npm install yarn@latest -g
 
bin
yarn global bin
 
binnode()
yarn config set prefix "自定义bin目录路径"
 
global
yarn global dir
 
yarn config set global-folder "F:\node\node_global\yarn_global"
 
cache
yarn cache dir
 
yarn config set cache-folder "F:\node\node_global\yarn_cache"
 
 
 
-----------------------
 
 
# 修改yarn安装包的位置
yarn config set global-folder "D:\appCache\yarn\global"
# 查看 yarn 全局安装位置
yarn global dir
# 改变 yarn 全局bin位置
yarn config set prefix "D:\software\Yarn\Data"
# 查看 yarn 全局bin位置
yarn global bin
# 修改缓存的位置
yarn config set cache-folder "D:\appCache\yarn\cache"
# 查看 yarn 全局cache位置
yarn cache dir
# 改变 yarn 全局 link 位置
yarn config set link-folder "D:\software\Yarn\Data\link"
 
 
评论(0)
暂无评论来抢沙发吧~