NPM is Node based JavaScript package registry. Thousands of packages and libraries are being added to npm daily. To publish a package to npmjs we should have
- A build project ready to publish
- Package.json
- npmjs.com account
- Readme.md
Name of Package
The name of the package, is the first thing to not in package file. Of course there are millions of already used packages, so the name may not be available, prefer another, make a search on the npmjs. Alternatively we can use scope in name. For example
@mongo/package_name
This will create private package, we can make it public when publishing it. Here the mongo is the npmjs username, and it should be.
Readme.md
Readme help developers to give some usage sample and basic information. If you don't know the standards, please install VSCode extension for generating README.
Other Package fields
Other fields in standard package files are
{
"name": "@meo/package_name",
"version": "1.0.0",
"description": "Awesome description",
"author": "Mumi",
"license": "MIT",
"keywords": ["color-picker","color","CSS","vuejs","vue-components"],
"repository": {
"url": "git://github.com/mue/vue-sfc.git"
},
....
}
Publish
Make sure , build the project properly. Go to terminal (cd into the project) and login to npm using credentials.
npm adduser
Make sure you are login
npm whoami
If you are using scoped name (@username/pkg) use the following command to make the package available to all
npm publish --access=public
or you can use the
npm publish
and it will be added to your package list on npmjs.
following npm posts may help you
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.