安装yarn:

这里直接使用的:

curl -o- -L https://yarnpkg.com/install.sh | bash

安装成功之后直接运行

yarn --version

提示:command not found: yarn

不要着急,可以找一下自己的 yarn 安装目录在哪里,一般在:
/Users/用户/.yarn
里边有个 bin 目录
使用指令:

open ~/.bash_profile

.bash_profile 最后添加一行

export PATH="/Users/用户/.yarn/bin:$PATH"

保存,之后运行

source ~/.bash_profile

再次运行 yarn --version
OK,大功告成

扩展:

yarn npm 说明
yarn npm install 安装全部依赖
yarn add *** npm install *** --save 安装运行依赖
yarn add *** --dev npm install *** --save-dev 安装开发依赖
yarn remove *** npm uninstall *** --save 卸载
yarn upgrade npm update 更新
yarn init npm init 初始化
yarn config get registry npm config get registry 查看当前仓库地址
yarn config set registry “https://registry.npm.taobao.org” npm config set registry “https://registry.npm.taobao.org” 更换仓库地址
安装 cnpm
npm install -g cnpm --registry=https://registry.npm.taobao.org

运行 cnpm --version OK

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐