-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
[BUG] npm install
not installing peer dependencies automatically and removing them from package-lock.json
#4934
Comments
npm install
not installing peer dependencies automatically
npm install
not installing peer dependencies automaticallynpm install
not installing peer dependencies automatically and removing them from package-lock.json
You should always explicitly include them, even though npm 7+ auto-installs them. |
Unfortunately, it was a bug that peer dependencies were installed when they weren't a dependency. Now that we're checking the lockfile with the dependency tree, you'll need to generate a new lockfile. |
For any future internet peepz landing here due to a Google search, check if you have a |
Since when? npm7 made a big deal about installing them after it was removed in a previous version https://github.blog/2021-02-02-npm-7-is-now-generally-available/#peer-dependencies |
To build on top of this, just know the error inducing .npmrc file can be in 4 places:
If you often work with React you may have hardcoded the --legacy-peer-deps flag into one of these config files and it is now overriding normal behaviour by not installing peer dependencies. |
I had this problem and it was caused by the following lines in
Removing those lines helped. Apparenly the issue it referenced has been fixed since nothing broke when I just deleted the lines. |
I had the same issue with npm not installing peer dependencies of packages. I had tried so many solutions, this worked for me.
2. enter this command, to see where you have .npmrc files on your PC: at the end of generated settings, you will see a locations of .npmrc files that are overriding something.
|
Is there an existing issue for this?
This issue exists in the latest npm version
Current Behavior
When running
npm install
, it does not install the peer dependencies automatically even if they are in the package-lock.json file.Instead it modifies the package-lock.json file removing all the peer dependencies.
Fwiw, the package-lock.json file was generated while we were using npm v7.
Expected Behavior
I was using npm v8.5.5 before upgrading today and on v8.5.5 all peer dependencies were being installed automatically (I guess we have them in our package-lock.json).
But now on the latest version v8.10.0 I am facing missing package errors while building.
Is this the intended behaviour now?
Steps To Reproduce
I can provide a minimal reproducible example if you can confirm that this is not intended/known.
Environment
If I remember correctly, npm 7 introduced the feature of auto installing peer dependencies. What is the stance on peer deps now in npm 8? Should we include all peer deps in our package.json?
The text was updated successfully, but these errors were encountered: