Npm执行install时的一些问题

Npm执行install时的一些问题

  首先,由于速度问题,建议更换淘宝源。但是,不推荐直接使用cnpm,因为cnpm与npm产生的目录结构等还是有不同的,有时会产生莫名其妙的bug。
⚡npm更换淘宝源

npm config set registry https://registry.npm.taobao.org
#还原
npm config set registry https://registry.npmjs.org/
#查看
npm config get registry

  顺便说一下,这样修改不会在.npmrc中增加registry =https://registry.npm.taobao.org

⚡sass换成淘宝的
  npm换成淘宝的源在安装sass的时候不知为何也会超时,设置一下就可以解决了。

npm config set sass_binary_site "https://npm.taobao.org/mirrors/node-sass"

⚡使用yarn
  如果还是有各种问题,可以尝试使用yarn,个人感觉还是不错的

npm install -g yarn
yarn config set registry https://registry.npm.taobao.org -g
yarn config set sass_binary_site http://cdn.npm.taobao.org/dist/node-sass -g

  这样安装有个问题,之后用yarn全局安装模块后模块不可以直接使用,比如全局安装了Vue,但vue命令直接使用是不可以的。如果不想麻烦的配置,直接去yarn官网下载.msi安装是个不错的选择。yarn官网下载安装包

快速上手yarn

Npm Yarn
npm init yarn init
npm install yarn / yarn install
npm link yarn link
npm install xxx --save yarn add xxx
npm uninstall xxx --save yarn remove xxx
npm install xxx --save -dev yarn add xxx --dev
npm update xxx --save yarn upgrade xxx
npm install xxx --global yarn global add xxx
npm publish / login / logout yarn publish / login / logout
npm run/test yarn run/test
npm get registry yarn config get registry
npm config set registry xxx yarn config set registry xxx
发布了118 篇原创文章 · 获赞 479 · 访问量 21万+

猜你喜欢

转载自blog.csdn.net/y_universe/article/details/104310532