-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
fix: lockfile not frozen when prefer-frozen-lockfile is set to true in .npmrc #9072
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix: lockfile not frozen when prefer-frozen-lockfile is set to true in .npmrc #9072
Conversation
💖 Thanks for opening this pull request! 💖 |
@@ -12,7 +12,8 @@ | |||
"removeComments": false, | |||
"sourceMap": true, | |||
"strict": true, | |||
"target": "es2021" | |||
"target": "es2021", | |||
"skipLibCheck": true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No idea why it kept complaining jest error 🤷 . I can't push to remote without it, feel free to remove before merging.
../../../../node_modules/.pnpm/@types+mocha@2.2.48/node_modules/@types/mocha/index.d.ts:66:18 - error TS2300: Duplicate identifier 'afterEach'.
66 declare function afterEach(description: string, callback: (this: Mocha.IBeforeAndAfterContext, done: MochaDone) => any): void;
opts.rawLocalConfig['frozen-lockfile'] !== false && | ||
opts.rawLocalConfig['prefer-frozen-lockfile'] !== false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when prefer-frozen-lockfile
is set to anything other than true
or false
, it will be treated as the default value which is true
.
default value for frozen-lockfile
is true
on CI as well. Otherwise it will return false
anyway.
TBH, I am a bit afraid of these changes as we already had many issues related to this. We might need to do a bigger refactor. |
When pnpm lock file is outdated
pnpm i --frozen-lockfile
->ERR_PNPM_OUTDATED_LOCKFILE
CI=1 pnpm i --frozen-lockfile
->ERR_PNPM_OUTDATED_LOCKFILE
However, after
echo prefer-frozen-lockfile=true > .npmrc
pnpm i --frozen-lockfile
->ERR_PNPM_OUTDATED_LOCKFILE
CI=1 pnpm i --frozen-lockfile
-> no errorThis issue can be reproduced in https://github.com/fa93hws/pnpm-freeze-lockfile-reproduce
After checking out
pnpm install --frozen-lockfile
failedCI=1 pnpm install
successCI=1 pnpm install
failed aftergit reset --hard
and comment outprefer-frozen-lockfile=true
After taking a look at the code, it's caused by checking whether the corresponding config is
undefined
or not. So even the value is set totrue
explicitly in.npmrc
, it's treated as false when deciding whether to freeze lockfile...