This article does not focus on YARN. Instead, it lists common project commands for quick use in projects. You can find more principles in another document
Create a new project
yarn init
Copy the code
And then a hint
Name (your-project): version (1.0.0): description: Entry point (index.js): Git repository: Author: License (MIT):Copy the code
Generate package.json file
{
"name": "my-new-project"."version": "1.0.0"."description": "My New Project description."."main": "index.js"."repository": {
"url": "https://example.com/your-username/my-new-project"."type": "git"
},
"author": "Your Name <[email protected]>"."license": "MIT"
}
Copy the code
Add, update, and delete dependencies
Yarn/yarn install One-click jpackage.json All packages YARN add [package] - If you add a package, the latest version is automatically installed, and the specified version is overwritten!! Yarn add [package]@[version] - Install the version yarn Remove [Package] Remove a package YARN Upgrade [package] Update a package yarn add vue Install a package yarn Add [email protected] Install a package yarn Upgrade vue Update a package yarn Upgrade [email protected] Update a package of a certain version yarn Remove vue yarn add vue Install dependencies yarn add vue --save-dev install devDependenciesCopy the code
NPM and YARN are compared
npm | yarn | usage |
---|---|---|
npm install | yarn install | Install all packages of package.json in one click |
npm install [package] –save / -S | yarn add [package] | Installed to the dependencies |
npm install [package] –save-dev/ -D | yarn add [package] –save-dev | Installed to the devDependencies |
NPM I [package]@[version number] | Yarn add [package]@[version number] | Specify the version number to download the update |
npm install [package] –global | yarn global add [package] | Install a package globally |
npm update –global | yarn updade upgrade | Update all packages |
npm uninstall [package] | yarn remove [package] | Deleting a package |