One of my work mate's PRs contains a package-lock.json update, which added "optional": true
:
"minimist": { "version": "0.0.8", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "minipass": {
I am not sure what this means even after googling around. Could someone please explain?
After a package is removed from dependencies, its dependencies are marked "optional": true in package-lock. json . It is usually safe to remove such packages either by hand or by $ rm -rf package-lock. json node_modules/ $ npm install. However, this is not 100% safe, as some packages will be updated to newer versions.
package-lock. json is automatically generated for any operations where npm modifies either the node_modules tree, or package. json . It describes the exact tree that was generated, such that subsequent installs are able to generate identical trees, regardless of intermediate dependency updates.
From https://docs.npmjs.com/files/package-lock.json#optional:
If true then this dependency is either an optional dependency ONLY of the top level module or a transitive dependency of one. This is false for dependencies that are both an optional dependency of the top level and a transitive dependency of a non-optional dependency of the top level.
It's safe to merge this change.
The reason you see this change is most likely because npm slightly changed how package-lock.json is structured in version 6.6. Your mate basically ran npm install
with npm 6.6+ on a package-lock.json previously generated with npm 6.5-.
You should be able to avoid this kind of issue by making sure everyone on your team uses a recent version of npm
.
After a package is removed from dependencies, its dependencies are marked "optional": true
in package-lock.json
.
It is usually safe to remove such packages either by hand or by
$ rm -rf package-lock.json node_modules/ $ npm install
However, this is not 100% safe, as some packages will be updated to newer versions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With