1

I have a fairly large number of packages that are outdated and I want to update. I tried running npm update as described in the npm documentation: npm update --depth 9999 -dev The update took a long time and at the end it failed. I tried a few more time, I set the stack size to unlimited, etc, but it always takes hours and at the end it fails.

I tried updating a single package with --depth 999 (not 9999) and that failed as well.

Is there any recommended way how to update all packages that works?

**Edit:** At first I was getting  `MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 error listeners added. Use emitter.setMaxListeners() to increase limit`

Then I got a heap exceeded exception:

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory

And finally, I got Max call stack size exceeded.

I set the stack size to unlimited and lowered the depth, but it's been running for hours with no result.

ventsyv
  • 2,781
  • 2
  • 23
  • 44
  • The `--depth` parameter is for recursively updating packages, and may not be what you want (i.e. let package creators deal with which version *they* install while updating all of the direct top level packages). – crashmstr May 28 '19 at 18:24
  • What error is shown when it fails? – davejagoda May 28 '19 at 18:25
  • What do you mean with update? Change `package.json` to last version of packages? Or just update `node_modules`? – Rashomon May 28 '19 at 18:26
  • 1
    If these are globally installed, you may want to consider moving away from global installs to directory-level installs. – Will Cain May 28 '19 at 18:27
  • @Rashomon. Both. – ventsyv May 28 '19 at 18:28
  • 1
    @WillCain No, they are all local – ventsyv May 28 '19 at 18:28
  • If you are using VSCode I highly recomend this extension: https://marketplace.visualstudio.com/items?itemName=pflannery.vscode-versionlens. You can check easily what version is installed and whats the last version – Rashomon May 28 '19 at 18:33
  • A `npm install` automatically updates the installed packages to last one (if you spicified the version with "^"). Not sure if exists a method to update the number on `package.json` (the previous suggested extension does it) – Rashomon May 28 '19 at 18:35
  • @Rashomon Not, VS, I'm running command line on Ubuntu. – ventsyv May 28 '19 at 18:53
  • @Rashomon I saw that but didn't notice the update so I assumed it's out of date (the question is 6 years old). Michael Cole's answer https://stackoverflow.com/a/30607722/2036161 is kind of what I was trying but the --depth flag threw me off. – ventsyv May 28 '19 at 19:20
  • https://medium.com/@jh3y/how-to-update-all-npm-packages-in-your-project-at-once-17a8981860ea this is the best solution I've found so far – Asif Ali Dec 19 '19 at 07:33

2 Answers2

3

It turns out I somehow had 4 npm update jobs running. I killed them, then ran npm outdated, took the output and ran npm install <package>@<version> for each package.

For good measure I then installed and ran npm-check-udates which installed another handful of packages.

Chris Owens
  • 4,468
  • 7
  • 49
  • 118
ventsyv
  • 2,781
  • 2
  • 23
  • 44
0

Run:

npm cache clean

and try again.

double-beep
  • 3,889
  • 12
  • 24
  • 35
cschaefer
  • 181
  • 8
  • This is worded like a question, not an answer. If you know this to be the answer, maybe just say "Run `npm cache clean` and try again." – Wyck May 28 '19 at 18:45
  • @Wyck I've edited that - it was clearly an attempt to answer the question, but bad formatted. – double-beep May 28 '19 at 18:58
  • I'll try that. I feel that the failed update attempt (and a couple I terminated early) are affecting things, so it's possible clearing the cache could help. – ventsyv May 28 '19 at 19:15