-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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] packages that are in devDependencies
AND optionalDependencies
are automatically added to package.json's dependencies
on npm install
#1886
Comments
I am noticing this same issue on npm 7.0.6, except it happens for packages with are only in |
As noted by feross, the actual bug here is that all This is a regression in the NPM 7.x line, caused by a large-scale rewrite which performs a mistaken normalisation step when loading the file, then saves its current (now normalised) view back out. Somebody made a PR (npm/normalize-package-data#110) to resolve the optionalDeps -> deps normalisation specifically, but since that normalisation is used in many places it may have other unintended consequences. There is more detailed information in the linked issues. |
I am noticing this bug too with |
same as: #724 |
Reify currently duplicates entries listed as optionalDependencies in the users' package.json files. While it's working as expected this is unexpected to a number of users and it also contradicts our own docs on it: Entries in optionalDependencies will override entries of the same name in dependencies, so it's usually best to only put in one place. This patches this UX problem by adding an extra check that will avoid adding a dependency to the package.json `dependencies` object in case that package is already listed under `optionalDependencies`. Fixes: npm/cli#2203 Fixes: npm/cli#1886 Fixes: npm/cli#724
Reify currently duplicates entries listed as optionalDependencies in the users' package.json files. While it's working as expected this is unexpected to a number of users and it also contradicts our own docs on it: Entries in optionalDependencies will override entries of the same name in dependencies, so it's usually best to only put in one place. This patches this UX problem by adding an extra check that will avoid adding a dependency to the package.json `dependencies` object in case that package is already listed under `optionalDependencies`. Fixes: npm/cli#2203 Fixes: npm/cli#1886 Fixes: npm/cli#724 EDIT(isaacs): Moved this into updateRootPackageJson in pairing session
Hi, I am not sure whether I should create a new issue, or continue this topic. I'd like to confirm if this is still an expected behaviour in In my case, I'd like to have them separated. As in npm ci --omit optional While working on a side project, I noticed that a package |
Current Behavior:
Packages that are in
devDependencies
ANDoptionalDependencies
are automatically added to package.json'sdependencies
onnpm install
.Expected Behavior:
npm install
shouldn't edit thepackage.json
.npm v6 docs states that
Entries in optionalDependencies will override entries of the same name in dependencies, so it’s usually best to only put in one place.
(https://docs.npmjs.com/files/package.json#optionaldependencies)Steps To Reproduce:
npm init -y
npm install noop --save-optional
npm install
dependencies
.Environment:
The text was updated successfully, but these errors were encountered: