Repository navigation
npm 12: Root 'prepare' script (Husky setup) is bypassed by default ignore-scripts and not targetable by approve-scripts #1647
|
With npm 12+ changing Context & ProblemIn projects adopting npm 12's security defaults:
This breaks the traditional zero-config DX where fresh clones automatically set up Git hooks upon Questions
Environment
|
Replies: 1 comment
|
The premise appears to mix two npm 12 settings. In npm 12, Root lifecycle scripts are intentionally outside If your organization deliberately enforces npm ci --ignore-scripts
npm run prepareA trusted repository can alternatively set References: https://docs.npmjs.com/cli/v12/using-npm/config/#ignore-scripts and https://typicode.github.io/husky/get-started.html |
The premise appears to mix two npm 12 settings. In npm 12,
ignore-scriptsstill defaults tofalse; the security change blocks unapproved dependency install scripts.Root lifecycle scripts are intentionally outside
npm approve-scripts. A normalnpm installornpm cistill runs the root"prepare": "husky"unlessignore-scripts=truewas explicitly configured. Husky itself has no lifecycle installer script to approve.If your organization deliberately enforces
ignore-scripts=true,allowScriptscannot override it. Use an explicit trusted step:A trusted repository can alternatively set
ignore-scripts=falsein its project.npmrc, subject to npm config pre…