MrSimonEmms
MrSimonEmms

Reputation: 1481

Error when trying to NPM Publish previously unpublished version

Whilst working on an NPM module while hungover (great plan), I bumped to the wrong version. "No problem" I thought. "I've done it before and solved with use of npm unpublish <module>@<version>." I did this and tried republishing yet it threw the error "cannot replace previously published version" despite this version not existing.

I decided to go nuclear. There was only 10 versions of my package so I decided to do npm unpublish <module> --force and start again from v0.0.1. I'm still getting the "cannot replace previously published version".

HELP!!! How can I fix this so I can put my package back?

Error log below

npm publish v0.0.1.tar.gz

npm http PUT https://registry.npmjs.org/datautils
npm http 403 https://registry.npmjs.org/datautils
npm http PUT https://registry.npmjs.org/datautils
npm http 403 https://registry.npmjs.org/datautils
npm ERR! publish Failed PUT 403
npm ERR! Error: forbidden Cannot replace previously published version: 0.0.1: datautils
npm ERR!     at RegClient.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js:275:14)
npm ERR!     at Request.self.callback (/usr/local/lib/node_modules/npm/node_modules/request/request.js:123:22)
npm ERR!     at Request.EventEmitter.emit (events.js:98:17)
npm ERR!     at Request.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/request/request.js:893:14)
npm ERR!     at Request.EventEmitter.emit (events.js:117:20)
npm ERR!     at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/request/request.js:844:12)
npm ERR!     at IncomingMessage.EventEmitter.emit (events.js:117:20)
npm ERR!     at _stream_readable.js:920:16
npm ERR!     at process._tickCallback (node.js:415:13)
npm ERR! If you need help, you may report this *entire* log,
npm ERR! including the npm and node versions, at:
npm ERR!     <http://github.com/isaacs/npm/issues>

npm ERR! System Linux 3.11.0-12-generic
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "publish" "datautils-js-0.0.1.tar.gz"
npm ERR! cwd /home/semms/Desktop/datautils
npm ERR! node -v v0.10.25
npm ERR! npm -v 1.3.24
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /home/semms/Desktop/datautils/npm-debug.log
npm ERR! not ok code 0

Upvotes: 11

Views: 10449

Answers (2)

Anenth
Anenth

Reputation: 702

You can unpublish the package if it's less than 24hr old

npm unpublish --force <package_name>@<version>

Upvotes: 3

vkurchatkin
vkurchatkin

Reputation: 13570

You can't do that anymore.

https://github.com/npm/npmjs.org/issues/148

TLDR: when you unpublish a version and then publish something else instead, you can break people's code, and so it's bad.

Upvotes: 17

Related Questions