You should go before or after thisyarn
Look at the official website.
The following commands can be found on the YARN CLI introduction page and are clearly described on the yarn CLI official website. If you don’t have the time, check out the following commands, but be sure to check out the official website.
NPM command | Yarn command | describe |
---|---|---|
npm init | yarn init | Initialize a new project |
npm install | yarn install | Install the project according to pageage.json |
npm install –global [package] | yarn global add [package] | Install a package globally |
npm install [–save]/[–save-dev] | yarn add /[-dev] | Add project dependencies/development dependencies |
npm run | yarn run | Run script in package.json |
Basic command on these a few, some NPM has abbreviations, consult by yourself. (The following is not used because NPM is to be abandoned) for example:
npm install
Can be written asnpm i
npm --global
I could just write it asnpm -g
npm install XXX --save
I could just write it asnpm i XXX -S
——–> Installation project dependenciesnpm install XXX --save-dev
I could just write it asnpm i XXX -D
——> Install development dependencies
There are fewer abbreviations for YARN, probably because I don’t know. Yarn. lock or package.json to install modules.
yarn.lock
The official website is very clear, you can go to yarn.lock.
All yarn.lock files should be committed to version control, which helps Yarn install exactly the same dependency tree on all machines. This feature is also added in nPM5.0 and later, called package-lock.json.
The advantage of a locked version is that depending on the same version, you can avoid a lot of embarrassing things that work on one computer, but may not run on another.
conclusion
Using YARN is faster than using NPM. CNPM is easy to lose dependencies. The locked-in version works so well that everyone uses the same version of dependency.
In fact, the best place to use YARN is the website. You are advised to visit it. Install NPM I yarn-G. Install NPM I yarn-G.