赞
踩
npm config get registry
npm config set registry https://registry.npm.taobao.org
npm config set registry https://registry.npmjs.org/
npm --registry https://registry.npm.taobao.org install XXX(模块名)
npm install -g cnpm --registry=https://registry.npm.taobao.org
cnpm install XXX(模块名)
npm install -g nrm
nrm use taobao
nrm ls // 查看当前可用源命令
npm install -g yarn
yarn config get registry
yarn config set registry https://registry.npmmirror.com
yarn config set registry https://registry.yarnpkg.com
yarn : 无法加载文件 F:\Web\nodejs\yarn.ps1。未对文件 F:\Web\nodejs\yarn.ps1 进行数字签名。无法在当前系统上运行该脚本。有关运行脚本和设置执行策略的详细信息,请参阅 https:/go.microsoft.com/fwlink/?LinkID=135170 中的 about_Execution_Policies。
所在位置 行:1 字符: 1
1.在windows搜索windows PowerSell,然后以管理员身份运行
2. 以管理员身份运行后,会出现命令窗口,接下来,输入命令 get-ExecutionPolicy 查看权限, 会看到它的返回值是 Restricted , 意思是 当前是禁用的。
3. 接下来,输入命令 set-ExecutionPolicy ,将权限设置为可用的,即可。
4. 关闭窗口,再使用 yarn 命令,就可以发现没有报错了。
npm install -g pnpm
pnpm config get registry
pnpm config set registry https://registry.npmmirror.com
pnpm config set registry https://registry.npmjs.org
npm、 yarn 和 pnpm 的区别和命令对比
说明 | yarn | npm/cnpm | pnpm |
---|---|---|---|
初始化某个项目 | yarn init | npm init | pnpm init |
默认安装依赖包 | yarn install/link | npm install/link | pnpm install/link |
安装某个依赖并默认保存到 package | yarn add **** | npm install **** --save | yarn add **** |
移除某个依赖 | yarn remove **** | npm uninstall **** --save | pnpm remove **** |
安装某个开发时的依赖 | yarn add **** -dev | npm install **** --save -dev | pnpm add **** -dev |
更新某个依赖项目 | yarn upgrade **** | npm update **** --save | pnpm upgrade **** |
安装某个全局依赖项目 | yarn add *** -g | npm install **** -g | pnpm add *** -g |
运行某个命令 | yarn run/test | npm run/test | pnpm run/test |
区别 | yarn 是 facebook 等公司在 npm v3 时推出的一个新的开源的包管理器,它的出现是为了弥补 npm 当时安装速度慢、依赖包版本不一致等问题。 | npm 是 Node Package Manager 的缩写,顾名思义是一个 NodeJS 包管理和分发工具,我们可以使用它发布、安装和卸载 NodeJS 包。npm 也是 Node.js 的默认的包管理器。一旦 node 安装,npm 也会被默认安装。 | pnpm 解决了 npm、yarn 重复文件过多、复用率低等问题 |
优点 | 并行安装,缓存,版本统一 | nodejs的包管理器,用于node插件管理 | pnpm继承了yarn的所有优点,包括离线模式和确定性安装 |
缺点 | 每个包都是复制到当前项目,毫无疑问,内存很快被占满。 | npm必须首先遍历所有的项目依赖关系,这是一个耗时的操作,是npm安装速度慢的一个很重要的原因。程序包没有签名,并且npm除了做了基本的SHA1哈希之外不执行任何完整性检查,这给安装系统程序带来了安全风险。 | - |
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。