玩转npm和yarn

npm和yarn淘宝镜像
// 设置
npm config set registry https://registry.npmmirror.com/
yarn config set registry https://registry.npmmirror.com/
// 查看
npm config get registry
yarn config get registry
node-sass 淘宝镜像设置
npm config set sass_binary_site https://npm.taobao.org/mirrors/node-sass/
yarn config set sass_binary_site https://npm.taobao.org/mirrors/node-sass/

homestead虚拟机,通过npm和yarn下载依赖包出错

  1. 在虚拟器运行 npm 下载依赖组件时报错:

npm ERR! EPROTO: protocol error, symlink ...

解决方案:

运行 npm 时增加参数 --no-bin-links

npm install --no-bin-links

使用 npm 重新生成 node-sass

npm rebuild node-sass --no-bin-links

在windows host中的vagrant box Linux中使用npm install时,由于host os不支持linux的symbol link,所以必须使用 --no-bin-links 命令

加速 npm 下载速度

npm config set registry https://registry.npmmirror.com/

2.yarn install 报错

error An unexpected error occurred: "EPROTO: protocol error, symlink '../../

删除应用里面的 node_modules 文件夹。
rm -rf node_modules
yarn install --save --no-bin-links

解决“mix: not found”错误的方法主要有以下几种:

1、在Windows 10宿主机中安装Node.js并执行npm install:在Windows 10宿主机中下载并安装Node.js后,执行npm install命令。完成后,在Homestead虚拟机内重新执行npm run dev命令,通常可以解决问题
2、使用--no-bin-links参数:在执行npm install时,使用--no-bin-links参数可以避免在node_modules文件夹下创建.bin文件夹,从而解决“mix: not found”错误。具体操作是在命令行中输入npm install --no-bin-links后再执行npm run dev

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容