Hey ๐Ÿ‘‹๐Ÿป

My name is Christian, an Agile Developer, living in Trento (IT)

I write good code at Wonderflow

You can follow me on and Github


More about me ๐Ÿค–




A story about npm publish / unpublish

npm
npm

Today I sat down and wrote a tiny package called wait-for-user-input. it can be used to wait for stdinย input in a command line script.

After I published the package on registry.npmjs.org, I noticed that I accidentally published it with the npm account from work..

calm down.

docs.npmjs.com/cli/unpublish to the rescue!

If no version is specified, or if all versions are removed then the root package entry is removed from the registry entirely.

So I ran a few npm unpublish by decrementing the version in the package.json, and the package was removed from npm.

npm, tell me who am i ๐Ÿ‘

npm whoami prints the username of the currently logged in user on the shell.

After a npm login command with my personal account credentials, I double checked that I was logged in with my personal account.

~/D/p/wait-for-user-input (master) npm whoami
          christian_fei

npm publish ๐Ÿ‘Ž

I was almost ready to publish to npm, but I was blocked by this error:

~/D/p/wait-for-user-input (master) npm publish
          npm ERR! publish Failed PUT 403
          npm ERR! code E403
          npm ERR! wait-for-user-input cannot be republished until 24 hours have passed. : wait-for-user-input
          ~/D/p/wait-for-user-input (master)

In fact, on docs.npmjs.com itโ€™s clearly written that:

with the default registry (registry.npmjs.org), unpublish is only allowed with versions published in the last 24 hours. If you are trying to unpublish a version published longer ago than that, contact [email protected]

next steps

So, now I need to:

  • ~wait 24 hours~
  • ~publish again under the correct npm account~

~Tomorrow Iโ€™ll update the article.~

Check out the updated section!

how to avoid

is there a prepublish hook that could check that the usernames from a github repo match the one on npm?

I donโ€™t know. Maybe one day Iโ€™ll find it out and report back.

Do you know if there is a way to have multiple npm accounts on the same shell? (e.g. ~/.aws/credentials)

โšก๏ธ it worked!

NPM

wait-for-user-input is available on npm!

(under the correct account this time ๐Ÿ˜…)