winney

It is never too old to learn.

0%
winney

yarn-笔记

yarn官网

yarn中文官网

yarn-中文官网

全局安装yarn

1
npm install --global yarn

查看版本

1
yarn --version

启动开发环境服务

1
yarn start

打包(生成静态文件)

1
yarn build

创建React项目

1
2
3
npx create-react-app my-app
cd my-app
yarn start

添加React Router

1
yarn add react-router-dom@6

使用Vite创建Vue项目

1
yarn create vite
1
2
3
4
√ Project name: ... Vue3_yarn
√ Package name: ... vue3-yarn
√ Select a framework: » vue
√ Select a variant: » vue-ts
1
2
3
cd Vue3_yarn
yarn
yarn dev

新建项目

1
yarn init
1
2
3
4
5
6
7
8
9
question name (yarn_test):
question version (1.0.0):
question description:
question entry point (index.js):
question repository url:
question author:
question license (MIT):
question private:
success Saved package.json

添加依赖

1
2
3
yarn add [package]
yarn add [package]@[version]
yarn add [package]@[tag]

将依赖项添加到不同的依赖类别中

1
2
yarn add [package] --dev  # dev dependencies
yarn add [package] --peer # peer dependencies

更新依赖

1
2
3
yarn upgrade [package]
yarn upgrade [package]@[version]
yarn upgrade [package]@[tag]

删除依赖

1
yarn remove [package]

根据package.json文件为项目安装所有依赖

1
yarn

or

1
yarn install

更新 Yarn 本体

1
2
yarn set version latest
yarn set version from sources