npm 运行:执行另一个(不正确的)脚本
npm run: Executes another (incorrect) script
这是我的 package.json
的 scripts
部分:
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"compile-prebuild": "tsc -p prebuild-tsconfig.json --pretty",
"prebuild": "ts-node --project PreBuild/tsconfig.json PreBuild/prebuild.ts",
"testJs": "node test.js",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"extract-i18n": "ng xi18n Paradise --i18n-format=xlf2 --output-path=i18n --i18n-locale=en && ng run Paradise:xliffmerge"
},
奇妙的是 当我尝试 npm run build
或 npm run build -- --prod
另一个脚本 (prebuild
) 被执行时 :
> npm run build -- --prod
> project@0.1.1 prebuild ...
> ts-node --project PreBuild/tsconfig.json PreBuild/prebuild.ts
现在,如果我将 prebuild
脚本重命名为 pre-build
(在 package.json
中),一切都会好起来的:
> npm run build -- --prod
> project@0.1.1 build ...
> ng build "--prod"
...
现在,如果我退回,问题又出现了!
> npm -v
6.7.0
这是 "correct",因为它是 npm
的记录行为 - 请参阅 here。
Additionally, arbitrary scripts can be executed by running npm run-script <stage>
. Pre and post commands with matching names will be run for those as well (e.g. premyscript
, myscript
, postmyscript
).
通常,脚本可以使用 pre
或 post
作为前缀,以便在脚本之前或之后执行操作。
在选择 npm 脚本名称时,最好将前缀 pre
和 post
视为保留前缀(除非您希望它们在主任务之前或之后始终为 运行,当然)。
pre 和 post 由 npm 自动挂钩 运行。如果您在 package.json 中定义了预构建,npm 将在您要求 运行 构建时自动 运行 它。 post 挂钩也是如此。
您可以在此处查看文档。 https://docs.npmjs.com/misc/scripts
这是我的 package.json
的 scripts
部分:
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"compile-prebuild": "tsc -p prebuild-tsconfig.json --pretty",
"prebuild": "ts-node --project PreBuild/tsconfig.json PreBuild/prebuild.ts",
"testJs": "node test.js",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"extract-i18n": "ng xi18n Paradise --i18n-format=xlf2 --output-path=i18n --i18n-locale=en && ng run Paradise:xliffmerge"
},
奇妙的是 当我尝试 npm run build
或 npm run build -- --prod
另一个脚本 (prebuild
) 被执行时 :
> npm run build -- --prod
> project@0.1.1 prebuild ...
> ts-node --project PreBuild/tsconfig.json PreBuild/prebuild.ts
现在,如果我将 prebuild
脚本重命名为 pre-build
(在 package.json
中),一切都会好起来的:
> npm run build -- --prod
> project@0.1.1 build ...
> ng build "--prod"
...
现在,如果我退回,问题又出现了!
> npm -v
6.7.0
这是 "correct",因为它是 npm
的记录行为 - 请参阅 here。
Additionally, arbitrary scripts can be executed by running
npm run-script <stage>
. Pre and post commands with matching names will be run for those as well (e.g.premyscript
,myscript
,postmyscript
).
通常,脚本可以使用 pre
或 post
作为前缀,以便在脚本之前或之后执行操作。
在选择 npm 脚本名称时,最好将前缀 pre
和 post
视为保留前缀(除非您希望它们在主任务之前或之后始终为 运行,当然)。
pre 和 post 由 npm 自动挂钩 运行。如果您在 package.json 中定义了预构建,npm 将在您要求 运行 构建时自动 运行 它。 post 挂钩也是如此。
您可以在此处查看文档。 https://docs.npmjs.com/misc/scripts