nodejs设置镜像

1、npm镜像地址配置

javascript 复制代码
-- 查看 npm 安装目录
npm root -g
 
-- 查看 npm 配置信息
npm config list

-- 查询当前镜像配置
npm get registry

-- 或者仅修改 npm 命令镜像
-- 设置为淘宝镜像
npm config set registry https://registry.npmmirror.com
-- 修改为官方镜像
npm config set registry https://registry.npmjs.org/


-- 查看、更改缓存及全局安装地址
-- 1、查看npm的prefix和cache路径配置信息
npm config get cache
npm config get prefix
-- 2、设置路径(路径包含空格必须引号)
npm config set prefix "C:\Users\happy\AppData\Roaming\nodejs\node_data\npm_global"
npm config set cache "C:\Users\happy\AppData\Roaming\nodejs\node_data\npm_cache"

-- 使用npm命令安装的全局插件会保存在prefix目录中,需要将此加入系统环境变量才可以执行已安装插件命令

2、yarn 安装

javascript 复制代码
-- yarn (安装速度快,并行下载,缓存机制,本地缓存,可以断网使用)
npm install yarn -g
 
 -- 查询镜像配置
yarn config get registry
-- 设置淘宝镜像
yarn config set registry https://registry.npmmirror.com
-- 设置为官方镜像
yarn config set registry https://registry.yarnpkg.com
 
-- 或者可以安装淘宝定制命令 tyarn
cnpm i yarn tyarn -g
-- 安装检查
tyarn -v
 
-- 查看、修改 yarn 安装及缓存位置
-- 1、全局安装及缓存位置
yarn config get prefix
yarn config get cache
-- 2、修改全局安装及缓存位置
yarn config set global-folder "C:\Users\happy\AppData\Roaming\nodejs\node_data\yarn_global"
yarn config set cache-folder "C:\Users\happy\AppData\Roaming\nodejs\node_data\yarn_cache"
 
-- 使用yarn命令安装的全局插件会保存在prefix目录中,需要将此加入系统环境变量才可以执行已安装插件命令
 
-- 代理设置
-- 同 NPM
相关推荐
不一样的信息安全3 小时前
Python Web框架比较:Flask与FastAPI的特性和应用场景
node.js
Along丶WG5 小时前
解决国内服务器 npm install 卡住的问题
前端·npm·node.js
prince_zxill5 小时前
Node.js 和 npm 安装教程
前端·javascript·vue.js·npm·node.js
谢尔登5 小时前
【Node.js】Koa2 整合接口文档
node.js
还是鼠鼠14 小时前
图书管理系统 Axios 源码__新增图书
前端·javascript·vscode·ajax·前端框架·node.js·bootstrap
还是鼠鼠17 小时前
图书管理系统 Axios 源码 __删除图书功能
前端·javascript·vscode·ajax·前端框架·node.js·bootstrap
鸠摩智首席音效师19 小时前
PM2 restart 和 reload “–update-env“ 选项的使用
node.js
落日弥漫的橘_2 天前
Node.js下载安装及环境配置教程 (详细版)
前端·node.js·环境配置·node安装教程
16年上任的CTO2 天前
一文大白话讲清楚webpack进阶——9——ModuleFederation实战
前端·webpack·node.js·模块联邦·federation
skinGap2 天前
Node.js 中文编码问题全解析
node.js·jenkins·android-studio