pnpm / pnpm

Fast, disk space efficient package manager
https://pnpm.io
MIT License
29.44k stars 990 forks source link

Vercel doesn't automatically install peerDependencies, `auto-install-peers=true` in .npmrc #5231

Open bryanltobing opened 2 years ago

bryanltobing commented 2 years ago

pnpm version:

Code to reproduce the issue:

https://github.com/bryantobing12/next-boilerplate

Steps to reproduce

in this repo, I have set in .npmrc file auto-install-peers=true

It works in my local developement and the peerDepedencies installed,

but when deploying to vercel, in the build process, the error appears because some peerDependencies cannot be found, in my case is @typescript/eslint-plugin that being used in eslint-config-airbnb-typescript

and i think it's because vercel doesn't detect .npmrc file and set the option to automatically install dependencies

Expected behavior:

Vercel read options set in .npmrc file, which in this case auto-install-peers=true so that It installing all required peerDependencies

Actual behavior:

Build error, because it missing some peerDependencies

Additional information:

zkochan commented 2 years ago

What version of pnpm Vercel uses? You can also try to run pnpm install --config.auto-install-peers=true.

By the way, if you commit the lockfile, probably all should work.

bryanltobing commented 2 years ago

Thanks for the response. I'm not sure about the exact version. but they claim to use v7 https://vercel.com/changelog/automatic-pnpm-v7-support. As you can see in the reproduced code, I committed the lock file.

What's weird is the error did not show up if I changed the install command to delete the lock file first. rm -rf pnpm-lock.yaml && pnpm install. But I'm not sure this fixed the issue. Because from what I know the lock file for all users should be the same to prevent inconsistencies right?

pnpm install --config.auto-install-peers=true

adding this isn't fixing the issue either

bryanltobing commented 2 years ago

Turns out the issue wasn't on vercel. it's pnpm that didn't consistent when installing dependencies.

We can reproduce with this repo.

note: I have set up auto-install-peers=true in .npmrc

Steps to reproduce.

image

and it makes sense the errors show up because it is not added to node_modules where it is supposed to be added since it's listed as peerDependencies in eslint-config-airbnb-typescript package

image.

@typescript-eslint/eslint-plugin finally added there image

why is this behavior happen? I don't want to always remove pnpm-lock.yaml before installing dependencies and It will create inconsistencies throughout the team