3

I have an innocent question :is there some interest to do a npm prune after a npm ci ? For me npm ci seems to be sufficient, no ?

Thanks by advance

RobC
  • 22,977
  • 20
  • 73
  • 80
  • 1
    Depending on what you want `npm prune --production` may be beneficial since it removes all devDependencies. – Marc Apr 29 '22 at 10:24

2 Answers2

6

since 'npm ci' removes the existing 'node_modules' before installing, there is no need to prune.

Npm prune removes extraneous packages installed inside your node_modules folder that aren't defined inside the package.json. This can not happen when you go from an empty node_modules folder.

madmed
  • 606
  • 6
  • 13
  • Do you have any reference that can prove your answer, or is it just a personal assumption? – Transcendent Jul 14 '18 at 15:09
  • If a node_modules is already present, it will be automatically removed before npm ci begins its install. https://docs.npmjs.com/cli/ci – madmed Jul 14 '18 at 18:32
  • What if there's a package that is added by the `ci` command, and it is still extraneous? – Transcendent Jul 14 '18 at 19:00
  • 1
    extraneous packages are packages that are installed inside your node_modules folder that aren't defined inside the package.json. This can not happen when you go from an empty node_modules folder. – madmed Jul 15 '18 at 00:32
  • 1
    Ok, fair enough, please edit your answer so that I can take back my downvote and change it to an upvote. – Transcendent Jul 15 '18 at 18:59
  • Thank you both for your answer – Hulkito Nol Jul 16 '18 at 09:09
0

but this is not valid answer of @madmed as of now, because after npm prune I have:

added 410 packages, removed 984 packages, and changed 10 packages in 32s

but npm ci desn't changes package-lock.json

So answer is: Yes you have interest. And I done it in my project to be sure that root package-lock.json was updated after my changes.

Michael Gaev
  • 69
  • 1
  • 3