node.jsnpmpublish

How I can publish NPM package with a name different one in package.json?


My package.json has

{
  "name": "package_name",
  "version": "1.0.1"
}

I want publish the package with name example_name. How I can do this?


Solution

  • When you run npm publish its look at your package.json, So the best thing to do is to change the name in the package.json, run npm publish and then change it back to the your desired name.

    You of course can write a script that will do it for you if you need to do it many times