Fel*_*ger 6 node.js npm package.json yarnpkg
下面是如何从另一个使用npmin运行脚本的示例package.json。
什么是等价物yarn?
{
"name": "npm-scripts-example",
"version": "1.0.0",
"description": "npm scripts example",
"scripts": {
"clean": "rimraf ./dist && mkdir dist",
"prebuild": "npm run clean",
}
}
Run Code Online (Sandbox Code Playgroud)
小智 9
改进@l-faros答案,Yarn 还支持更短的语法
{
"scripts": {
"clean": "rimraf ./dist && mkdir dist",
"prebuild": "yarn clean",
}
}
Run Code Online (Sandbox Code Playgroud)
并yarn prebuild运行脚本命令。
该语法允许省略参数run。文档:https://classic.yarnpkg.com/en/docs/cli/#toc-user-defined-scripts
你可以做
{
"name": "npm-scripts-example",
"version": "1.0.0",
"description": "npm scripts example",
"scripts": {
"clean": "rimraf ./dist && mkdir dist",
"prebuild": "yarn run clean",
}
}
Run Code Online (Sandbox Code Playgroud)
然后命令yarn run prebuild应该可以工作。你也可以这样做yarn run clean。
runcli 的文档:https : //yarnpkg.com/lang/en/docs/cli/run/
| 归档时间: |
|
| 查看次数: |
3314 次 |
| 最近记录: |