Software hacker working in the industry since 2003. Currently loves: #Typescript and #Svelte and #golang. Founder of Chimera, the first makerspace in northern California.
For a lil more background, there is a difference between the behaviors of npm install --production, npm ci --only=prod, and --npm ci omit=dev:
npm install --production exhibits the same behavior that npm install does when you have a NODE_ENV=production environment variable set. So you can either set your NODE_ENV environment variable to production (recommended) or you could set this flag on npm install (or both to ensure that you get the behavior you want just in case something goes wrong with the environment variable!).
npm ci --only=prod and npm ci --omit=dev actually seem rather similar from what I could find. The only concern I would have with npm ci --only=prod is that it's not documented at all - only npm ci --include=prod is, but that could be because the documentation has changed since this article/comment was posted!
Anyways, npm ci --omit=dev prevents npm ci from installing devDependencies, however with this option the devDependencies are still included in the package-lock.json or npm-shrinkwrap.json files. This way, users can always manually install the devDependencies themselves later using npm ci --include=dev if they wish to develop the project. (See this documentation for further information.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
What are your opinions comparing this method
npm install --only=prod
withnpm ci
?I found that
npm ci --only=prod
works as well (see link)You're correct.
npm ci
also installs dev dependencies.Adding
--only=prod
or--production
would not installdevDependencies
and just installdependencies
.I'll update the article to show both options 👍
It's now recommended to use
--omit=dev
over--production
😆 Good ole Node.js.For a lil more background, there is a difference between the behaviors of
npm install --production
,npm ci --only=prod
, and--npm ci omit=dev
:npm install --production
exhibits the same behavior thatnpm install
does when you have aNODE_ENV=production
environment variable set. So you can either set yourNODE_ENV
environment variable to production (recommended) or you could set this flag onnpm install
(or both to ensure that you get the behavior you want just in case something goes wrong with the environment variable!).npm ci --only=prod
andnpm ci --omit=dev
actually seem rather similar from what I could find. The only concern I would have withnpm ci --only=prod
is that it's not documented at all - onlynpm ci --include=prod
is, but that could be because the documentation has changed since this article/comment was posted!Anyways,
npm ci --omit=dev
preventsnpm ci
from installingdevDependencies
, however with this option thedevDependencies
are still included in the package-lock.json or npm-shrinkwrap.json files. This way, users can always manually install thedevDependencies
themselves later usingnpm ci --include=dev
if they wish to develop the project. (See this documentation for further information.