我已经安装了一个名为@company/cdk-library的自定义包。
它有package.json脚本:
"scripts": {
"test": "jest",
"build": "tsc",
"prepublishOnly": "npx tsc --skipLibCheck",
"installLambdas": "(cd constructs/account/mylambda/code/ && npm i)",
"postinstall": "npm run installLambdas"
},
当我使用以下命令将此软件包安装到我的项目中时:npm i @mycompany/cdk-library@5.0.0 --foreground-script
我没有收到任何指示表明它已运行postinstall
脚本。如果我检查目录,也没有依赖项。
安装输出:
➜ cdk git:(cdk-update) ✗ npm i @mycompany/cdk-library@5.0.0 --foreground-scripts
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated source-map-url@0.4.1: See https://github.com/lydell/source-map-url#deprecated
npm WARN deprecated source-map-resolve@0.5.3: See https://github.com/lydell/source-map-resolve#deprecated
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated sane@4.1.0: some dependency vulnerabilities fixed, support for node < 10 dropped, and newer ECMAScript syntax/features added
added 504 packages, and audited 523 packages in 16s
25 packages are looking for funding
run `npm fund` for details
1 critical severity vulnerability
To address all issues, run:
npm audit fix
Run `npm audit` for details.
然而,如果我通过手动运行cd node_modules/@mycompany/cdk-library && npm run postinstall
来执行它
它可以正常运行,输出如下:
cdk-library git:(cdk-update) ✗ npm run postinstall
> @mycompany/cdk-library@5.0.0 postinstall
> npm run installLambdas
npm WARN deprecated axios@0.19.2: Critical security vulnerability fixed in v0.21.1. For more information, see https://github.com/axios/axios/pull/3410
added 82 packages, and audited 83 packages in 1s
...
有人知道为什么我安装包时postinstall没有运行吗?
7.17.0
测试了postintall,它可以正常运行。 - Lalaluka