install
npm install -g yarn
npm config set registry=[http://registry.npmmirror.com](http://registry.npmmirror.com/)
改变 yarn 全局安装位置
yarn config set global-folder "你的磁盘路径"
然后你会在你的用户目录找到 .yarnrc 的文件,打开它,找到 global-folder ,改为 --global-folder
这里是我的路径
yarn config set global-folder "D:\nodejs\yarn\global"
改变 yarn 缓存位置
yarn config set cache-folder "你的磁盘路径"
这里是我的路径
yarn config set cache-folder "D:\nodejs\yarn\cache"
在我们使用 全局安装 包的时候,会在 “D:\Software\yarn\global” 下 生成 node_modules.bin 目录
我们需要将 D:\Software\yarn\global\node_modules.bin 整个目录 添加到系统环境变量中去,否则通过yarn 添加的全局包 在cmd 中是找不到的。
检查当前yarn 的 bin的 位置
yarn global bin
检查当前 yarn 的 全局安装位置
yarn global dir
Yarn安装包位置
C:\Users\xxx\AppData\Local\Yarn\global\node_modules.bin
缓存位置
C:\Users\xxx\AppData\Local\Yarn\Cache
修改yarn安装包的位置
yarn config set global-folder "D:\appCache\yarn\global"
查看 yarn 全局安装位置
yarn global dir
改变 yarn 全局bin位置
yarn config set prefix "D:\software\Yarn\Data"
查看 yarn 全局bin位置
yarn global bin
修改缓存的位置
yarn config set cache-folder "D:\appCache\yarn\cache"
查看 yarn 全局cache位置
yarn cache dir
改变 yarn 全局 link 位置
yarn config set link-folder "D:\software\Yarn\Data\link"
yarn config set registry=[http://registry.npmmirror.com](http://registry.npmmirror.com/)
yarn config set registry=<https://registry.npmmirror.com/>
Microsoft VS Code修改目录
"D:\Program Files\Microsoft VS Code\Code.exe" --extensions-dir "D:\Program Files\Microsoft VS Code.vscode\extensions"
一些常用的Yarn命令
- yarn init // 生成package.json文件
- yarn install // 安装yarn.lock的所有依赖
- yarn install --force // 重新安装依赖
- yarn remove moduleName // 删除依赖
- yarn add moduleName // 安装某个依赖
- yarn add moduleName --dev/-D // 安装到开发环境
- yarn run scriptName // 执行package.json命名的脚本命令
错误信息
gyp verb check python checking for Python executable "python2" in the PATH
解决办法:
C:\Users\thomashe.windows-build-tools\python27
npm config set python C:\Users\thomashe.windows-build-tools\python27\python.exe
error MSB4019: 未找到导入的项 目“D:\Microsoft.Cpp.Default.props”。请确认 声明中的路径正确,且磁盘上存在该文件。
npm config set msvs_version 2017
npm i node-sass --sass_binary_site=npm.taobao.org/mirrors/nod…
- npm install
- npm run dev