Publish the Nuxt CLI to NPM Package

Sherly Febrianti
Towards Dev
Published in
3 min readApr 9, 2021

--

Hi CelSius, — that’s how i call my pal 😆

After building the Nuxt-CLI using NPM, now it’s time to register it in NPM Package.

Login to your NPM account

First, you need to have an NPM account and do the login.

Login to your NPM account

Publish the Nuxt-CLI project

After make sure you have the NPM account, go to Nuxt-CLI project.

Login to your NPM account from terminal.

npm login

Run this command to publish the project.

npm publish

Error Handling when Publish the Nuxt-CLI project

After running the publish command, you will get an error 400 invalid new package.

Error on npm Publish with 400 invalid new package

Add publishConfig to your package.json file :

{
...
"publishConfig": {
"access": "public",
}
}

Re-run the npm publish again.

Error on npm Publish with invalid package name

It will showing you that the name property on package.json is invalid.

Change the name property on package.json :

{
"name": "nuxt-cli-class-component",
...
...
}

In this case, i will rename nuxt-cli to nuxt-cli-class-component since the name seems like it has been exist in NPM Package.

Re-run the npm publish again.

In this case, i still got a new error.

Error on npm Publish : project is not in the npm registry

If you find the error above, it means something wrong with the access.

In this case, we will use npm adduser to verify our username.

npm adduser
Verify the npm username

After the user has been verified, we will re-run again.

npm publish --scope=<your-username-here> --access public

Tadaaa~~

NPM Package has been published successfully

Now our Nuxt-CLI has been published successfully.

NPM Package has been published

Summary

If you don’t like the long explanation, here is the checklist you have to do :

  • Login to your NPM account
  • Publish the Nuxt-CLI project
  • Error Handling when Publish the Nuxt-CLI project

Now, you are good to go. Cheers!

--

--