Repository navigation
Closed
Labels
Milestone
Description
Current Behavior:
npm ci --production installs dependencies marked as dev in package-lock.json.
Expected Behavior:
I expect npm ci to not install any packages marked as dev in lockfile.
npm 6 behaves as expected and installs only production dependencies with --production flag.
In example below, I expect @types/yargs to not be installed for production.
Steps To Reproduce:
npm init -y
npm i yargs && npm i -D @types/yargs
npm ci
ls node_modules
npm ci --production
ls node_modules
Expected output (npm 6.14.8)
$ npm ci
npm WARN prepare removing existing node_modules/ before installation
added 18 packages in 0.295s
$ ls node_modules
ansi-regex cliui color-name escalade is-fullwidth-code-point string-width @types y18n yargs-parser
ansi-styles color-convert emoji-regex get-caller-file require-directory strip-ansi wrap-ansi yargs
$ npm ci --production
npm WARN prepare removing existing node_modules/ before installation
added 16 packages in 0.263s
$ ls node_modules
ansi-regex cliui color-name escalade is-fullwidth-code-point string-width wrap-ansi yargs
ansi-styles color-convert emoji-regex get-caller-file require-directory strip-ansi y18n yargs-parser
Actual output (npm 7.0.3)
$ npm ci
added 18 packages, and audited 18 packages in 846ms
2 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
$ ls node_modules
ansi-regex cliui color-name escalade is-fullwidth-code-point string-width @types y18n yargs-parser
ansi-styles color-convert emoji-regex get-caller-file require-directory strip-ansi wrap-ansi yargs
$ npm ci --production
added 18 packages, and audited 18 packages in 821ms
2 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
$ ls node_modules
ansi-regex cliui color-name escalade is-fullwidth-code-point string-width @types y18n yargs-parser
ansi-styles color-convert emoji-regex get-caller-file require-directory strip-ansi wrap-ansi yargs
Environment:
- OS: Ubuntu 20.04
- Node: 12.9.1
- npm: 7.0.3
NODE_ENVis empty
Reacted by escalonn, Julian Kleine, Pavel Shakhov, Ben Harrop, yutopp, Leandro Aguiar, Blaise Kal and sam
Activity
juliankleine commentedon Oct 26, 2020
Also ignores
NODE_ENVTested with
NODE_ENV=production npm cifix: pass flatOptions through to Arborist.reify in npm ci
fix: pass flatOptions through to Arborist.reify in npm ci
fix: pass flatOptions through to Arborist.reify in npm ci
Ketler13 commentedon Aug 3, 2021
It happens again in 7.20.3. Does anyone have the same problems?
cheslijones commentedon Oct 2, 2021
I'm running into this issue with 7.24.0 as I've explained here.
Using either
npm install --productionornpm ci --productionwhen youdocker run -it <image_id> bashand look atnode_modules, all of thedevDependenciesare in there likejestandestlint.isaacs commentedon Oct 5, 2021
@cheslijones works for me here:
Is it possible that you have something with a production dependency on one of your devDependencies? Can you inspect your package-lock.json file and see if those dev deps have
"dev": truein their lockfile entries?cheslijones commentedon Oct 5, 2021
Sorry, disregard. I didn't realize that by
jestandeslintbeing part ofreact-scripts(a production dependency) increate-react-appthat it would automatically makejestandeslinta production dependency.isaacs commentedon Oct 6, 2021
@cheslijones happy to help :)
Piliponful commentedon Jun 7, 2022
There are no flag --production in npm ci docs https://docs.npmjs.com/cli/v8/commands/npm-ci
And if you think how it works you'll understand why.
npm ci installs all the packages from package-lock.json so what would flag production mean?
s3nPy commentedon Jun 21, 2022
@Piliponful Because after
npm install --only=prodi runnpm ci --only=prodand get:Error: cipm can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync. Please update your lock file withnpm installbefore continuing.Log also with some missing packages errors that are clearly not in package-lock.json.