23

I have a package which I released on NPM and it's currently at version 1.0.1.

I have made some changes locally, and wanted to publish them. I entered npm version 1.0.3 and then felt stupid, because I wanted to type npm version 1.0.2.

How can I restore this mistake?

Stephan Bijzitter
  • 4,425
  • 5
  • 24
  • 44

1 Answers1

45

A colleague just suggested to reset my repository to the remote repository and try again, it worked.

I first used the following commands to reset my repository's master branch (as if it's a clean clone):

git fetch origin
git reset --hard origin/master

Also delete the tags from local and remote git tag -d 1.0.2 Remove from local repo git push --delete origin 1.0.2 remove from remote repo

Then I simply added the version:

npm version 1.0.2
shekhardtu
  • 4,335
  • 7
  • 27
  • 34
Stephan Bijzitter
  • 4,425
  • 5
  • 24
  • 44
  • 11
    For anyone else that finds this, you also need to make sure to delete the tag created. `git tag -d v1.0.3` – Matt McClure Dec 15 '18 at 00:21
  • If you haven't published to npm yet, you can edit the version in the package.json Change `"version": "1.0.0"` to `"version": "0.0.0",` or whatever your usecase may be. – Osinachi Dec 29 '20 at 13:29