【发布时间】:2020-03-22 19:56:20
【问题描述】:
下面是一个示例,如何使用npm 在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",
}
}
【问题讨论】:
-
"prebuild": "yarn run clean",然后yarn run prebuild应该工作不?你可以做yarn run cleantho -
因为我用
"scripts": {"test": "yarn -v", "test2": "yarn run test" }进行了测试,然后yarn run test2工作得很好。同样根据yarnpkg.com/lang/fr/docs/cli/run yarn run 应该只适用于 package.json 脚本部分中的任何脚本 -
对不起,你是 100% 正确的。不知道为什么它最初对我不起作用。
-
没问题,很高兴能帮到你:)
标签: node.js npm yarnpkg package.json