Official Description: https://classic.yarnpkg.com/zh-Hans/docs/package-json
Original Address: Use the command of yarn
name
And version
is a package.json
document the two most important fields, without which your package can not be installed. name
And version
fields together to create a unique id.
yarn add [name]
This is the name of your package. It is in the URL, as command line arguments as node_modules
directory names in use.
node_modules/[name] https://registry.npmjs.org/[name]/-/[name]-[version].tgz
Add a dependency
By
yarn add
updates add dependenciespackage.json
andyarn.lock
files
yarn add <packageName>
Dependence will be recorded inpackage.json
thedependencies
yarn global add <packageName>
Global Installation depends
Update a dependent
yarn upgrade
The latest version of the update package to be used based on the specification range
yarn upgrade --latest # 忽略版本规则,升级到最新版本,并且更新 package.json
Removing a dependent
yarn remove <packageName>
Install all the files package.json
yarn
oryarn install
Run the script
yarn run
To executepackage.json
thescripts
script attributes defined under
// package.json
{
"scripts": {
"dev": "node app.js", "start": "node app.js" } }
yarn run dev # yarn 执行 dev 对应的脚本 node app.js
npm run # npm
yarn start # yarn npm start # npm
And you can have the same npm
yarn start
andyarn test
two shorthand way of running the script
A display package information
yarn info <packageName>
A module can be used to view the latest version information
All rely listed items
yarn list
# 列出当前项目的依赖
yarn global list # 列出全局安装的模块