Publish the Nuxt CLI to NPM Package
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.
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.
Add publishConfig
to your package.json
file :
{
...
"publishConfig": {
"access": "public",
}
}
Re-run the npm publish
again.
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.
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
After the user has been verified, we will re-run again.
npm publish --scope=<your-username-here> --access public
Tadaaa~~
Now our Nuxt-CLI has been published successfully.
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!
The next thing you can do :