1、在 D盘新建一个目录,用来存放 npm 或 yarn 的 cache 和 依赖包文件

我这里新建的文件夹如下:

D:\node_package\npm

D:\node_package\npm_cache

D:\node_package\yarn

D:\node_package\yarn_cache

 

2、更改npm  和 yarn  的配置

# npm
npm config set prefix "D:\node_package\npm"
npm config set cache "D:\node_package\npm_cache"

# yarn
yarn config set global-folder "D:\node_package\yarn"
yarn config set cache-folder "D:\node_package\yarn_cache"

 

3、查看配置

# npm 
npm config list

# yarn
yarn config list

 

4、为了让安装的包,能在控制台使用,需要配置 Path 环境变量

1)新建 NODE_PATH 环境变量

npm和yarn更改依赖包全局下载和缓存路径

 

 2)在 Path 中添加如下路径

%NODE_HOME%\npm

%NODE_HOME%\yarn\node_modules\.bin

npm和yarn更改依赖包全局下载和缓存路径

 

相关文章:

  • 2021-11-19
  • 2021-07-01
  • 2022-12-23
  • 2021-12-10
  • 2021-04-09
  • 2022-12-23
  • 2021-12-23
  • 2022-12-23
猜你喜欢
  • 2021-08-04
  • 2022-12-23
  • 2022-12-23
  • 2021-06-30
  • 2022-12-23
  • 2021-08-12
相关资源
相似解决方案