Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign uppackage-lock.json and optional packages #17722
Comments
|
|
|
We have the exact same problem. Developers use MacOS and Linux across our team and a simple Is there a flag to do the opposite of |
|
We also can not force to use |
|
@Strate I agree, it can also be the other way around - it might even make more sense: treat At the end this is what we want, using How is that issue managed using Edit: On the other hand, if you use the |
|
Hey team, any updates on this? We're getting really close to having |
|
We have this issue on Travis CI with package To prevent the issue we install packages with flag:
|
|
We have the same issue in my team, I don't understand why "npm install" on windows/linux removes fsevents from package-lock.json. The documentation states that it should be there always: https://docs.npmjs.com/files/package-lock.json |
|
Using So I would really like to see a flag to assert that the lockfile and node_modules is in sync, and incorporated into the |
|
An added flag like Perhaps the lockfile format should be extended so that optional dependencies are annotated as such - … and then I noticed that the lockfile does have |
|
|
|
Our team also have the same problem which is really annoying, because each reviewer should check what was changed in package-lock. Maybe like @00dani propose add all optionals with a flag? |
|
Is there a workaround for this issue, other than using --no-save? |
|
As workaround I see the only solution - not to commit package-lock.json if you don't change package.json |
|
If something is non optional and platform specific it doesn't seem enough to describe that with "optionalDependencies". Until then we will see scripts & solutions like this https://github.com/bertofer/npm-platform-dependencies. If the lock-file is supposed to be an immutable representation of an install to reproduce its not entirely possible if the os isn't recorded as well. Maybe we need platform specfic lock files or an addition in there that is platform specific? Ideally I'd like to see cross platform development as frictionless as possible. Platform specific dependencies should be described as what they are. imo:
Also |
|
Making the whole lockfile platform-specific - Pushing platform-specific packages into a special subtree of the lockfile would be fine, though. How 'bout this? "dependencies": {"some-package": {...}, "some-other-package": {...}, ...},
"osDependencies": {
"darwin": {"some-mac-package": {...}, ...},
"linux": {"some-linux-package": {...}, ...}
}If added, |
|
Yes thats what I had in mind @00dani and it would probably need to support |
|
The lockfile would handle It's trickier for package.json, however, since that file has actual separate sections for {
"name": "chokidar",
"dependencies": {"anymatch": "^1.3.0", ...},
"os": {
"darwin": {"dependencies": {"fsevents": "^1.0.0", ...}}
}
} |
|
Split optional dependencies into separate folders with separate package.json files. Not the cleanest solution but very simple. Can have a different folder for mac/Linux/windows/developers/CI. |
I'm opening this issue because:
What's going wrong?
Npm accidently make changes to package-lock.json
How can the CLI team reproduce the problem?
Assume you have a 2 developers, one on mac, and one on linux. You use npm@5.1 and your project depends on
chokidarpackage. That package has optional dependency offsevents, which is useful only for mac. So, you are on linux, and donpm i chokidar. npm generates package-lock.json withous fsevents, because it is useless on linux. You commit that generated file.Your teammate pulls your changes, and do
npm i, to getnode_modulesin sync withpackage-lock.json. Npm installsfsevents, and write it topackage-lock.json. What should mac user to do? commit that file?Assume that mac user commits file. Linux user pulls it, and make
npm install. Npm does not installfsevents, and remove it frompackage-lock.json. And this become annoying very quickly.How lock files could be used in this case?
supporting information:
npm -vprints: 5.1.0node -vprints: v6.10.0npm config get registryprints: undefined