Solving ‘panic: runtime error: index out of range’ with Node.js Update

The Goal

You already have NVM and Node.js installed from a while ago and you want to upgrade them before you set out on your latest coding adventure.

Getting Started

  1. Open Windows PowerShell.
  2. Verify that NVM is installed by entering:
    nvm --version
  3. Use the NVM command to update Node.js:
    nvm install latest

Ah, were it only so simple! (But maybe it worked for you; have a great day!)

The ‘Panic’ Error

You may get this error message:

panic: runtime error: index out of range

What?!! You may chuckle at an error message that begins with “panic,” but panic and frustration start rising anyway. As my high school physics teacher used to like to quote: “When in danger, when in doubt, run in circles, scream and shout!” When you have finished expressing yourself, move on.

Corey Butler gives the reason for this error:

When Node released v19, they quietly added a new ARM installer that breaks the regex pattern used to identify the appropriate file. This is accounted for in v1.1.11+.

NVM install fails with a runtime error: index #984” at GitHub

How to Fix the ‘Panic’ Error

The solution turns out to be easy enough, but it takes a few steps, as follows:

  1. Download the “nvm-update.zip” file at Corey Butler’s nvm-windows releases page. While you are there, also download the nvm-update.zip.checksum.txt file just below it to use in the next step. Also make note of the latest version number for NVM, which you will need in Step 4. (The latest version number shows at the top of the main content area for that page.)
  2. Run checksum on the zip file to verify its authenticity by typing the following in PowerShell:
    certutil -hashfile [path to your file]\nvm-update.zip MD5
  3. Extract the file in the zip file, nvm-update.exe.
  4. Run nvm-update.exe. The run procedure will ask for what version you wish to upgrade to. Enter that and continue.

When you have finished, you should be able to enter “nvm install latest” into PowerShell and have it actually work.

Conclusion

If this NVM error prevented you from updating Node.js, I hope you found my instructions helpful. If you have any questions, you may contact me or leave a comment below.

Now you can get on with your day and do the cool stuff, like learn to use the new WordPress Interactivity API from this tutorial by Jonathan Bossenger at WordPress TV.

Leave a Comment

TOC