What does "dev" true
means in package-lock.json
file?
In my case it is automatically updated when I perform npm
operations.
How can we remove it?
What does "dev" true
means in package-lock.json
file?
In my case it is automatically updated when I perform npm
operations.
How can we remove it?
So answering your first question, "dev": true
in package-lock.json
means this dependency won't be installed by npm install
/npm ci
when running in production
mode.
Having dependencies used only for local development environment marked with "dev": true
and then using --production
in your CI might save you some build time.
From documentation https://docs.npmjs.com/cli/install#description:
By default,
npm install
will install all modules listed as dependencies inpackage.json
.With the
--production
flag (or when theNODE_ENV
environment variable is set toproduction
), npm will not install modules listed indevDependencies
.
I think this paragraph tries to illustrate how the package dependency's dev: true is assigned.
dev: true
dev: true
dev: true
In other words, once a develop dependency package is indirectly dependent by a non-development package, it shall be dev: false
and thus it will be included in the build process. The purpose of this rule is to make sure that packages needed by the non-develop package will not have "dev: true"
.
Besides, if I install via npm install -D <name>
, then the package will be installed as the develop package thus no dev: true
changes may occur. However, if install via npm install <name>
, this may remove many existing dependencies' "dev: true"
attribute.
For example, I run npm install -D bestzip
in my project and the result is:
Run npm install bestzip
and the result is:
From the npm docs at https://docs.npmjs.com/files/package-lock.json
If true then this dependency is either a development dependency ONLY of the top level module or a transitive dependency of one. This is false for dependencies that are both a development dependency of the top level and a transitive dependency of a non-development dependency of the top level.