How to access previous versions of an npm package?

I’m working on some npm packages and I’ve been putting out alpha versions for testing (like 1.0.16-alpha.1). But I’m running into a problem. It seems like the older versions are disappearing from the npm repo. Is this normal?

I tried to do some digging on my own. When I use npm install package@old-version in the command line, it works fine. But when I try to npm install in a project where it’s listed as a devDependency, I sometimes get errors. I can’t figure out the pattern.

Are these old versions actually getting deleted? Or am I missing something? If they are being removed, is there a way to keep them around in npm?

This is causing a real headache for my development process. Any help or insight would be much appreciated!

I’ve encountered similar issues before, and it can indeed be frustrating. NPM doesn’t typically delete old versions, but there are a few scenarios that might explain what you’re experiencing.

First, check if you’ve set a ‘dist-tag’ for your package. Sometimes, alpha versions are tagged differently and may not be visible in the default view. You can use ‘npm dist-tag ls ’ to see all tags.

Another possibility is that you’ve hit NPM’s storage limits for unpublished versions. NPM only keeps the last 24 hours of unpublished versions. If you’re frequently publishing and unpublishing, older versions might disappear.

For your devDependency issue, ensure your package.json specifies the exact version you need, including the alpha tag. Something like ‘1.0.16-alpha.1’ should work.

Lastly, consider using a private registry or a tool like Verdaccio for more control over your package versions during development.

I’ve been down this road before, and it can be a real pain. From my experience, npm doesn’t usually delete old versions, but there are a few quirks that might explain what you’re seeing.

One thing to check is your npm cache. Sometimes it can get out of sync and cause weird issues. Try running ‘npm cache clean --force’ and then attempt your install again.

Another possibility is that you’re hitting npm’s unpublish time limit. They only allow you to unpublish a version within the first 72 hours after publishing. After that, it’s locked in. This policy can sometimes lead to confusion about version availability.

For your devDependency problem, make sure you’re using the exact version syntax in your package.json. For alpha versions, it should look like ‘1.0.16-alpha.1’. Also, double-check that you’re not accidentally using a different registry for some of your installs.

If you’re still having trouble, you might want to consider using npm’s ‘deprecated’ feature instead of trying to remove old versions. It allows you to flag versions as obsolete without actually deleting them.

hey, i’ve run into this too. npm can be a pain sometimes! make sure ur using the exact version in package.json like ‘1.0.16-alpha.1’. also, try clearing ur npm cache with ‘npm cache clean --force’. if that doesn’t work, maybe ur hitting the 72-hour unpublish limit? npm locks versions after that. hope this helps!