npm init
Note: define your module name in name
field of package.json
.
entry
is a file that return object method for the require('your_module_name')
call.
Can be config in main
field of package.json
npm login
npm whoami
npm publish
# Anthor directory
npm install your-package-name
const myModule = require('your-package-name');
myModule();
- If it occurs an error message that
you do not have permission to publish "your module name", Are you logged in as the correct user?
, that means this module had alredy existed. - If you update module and want to republish, you must update your module version file in package.json, you can use the npm cli
npm version major/minor/patch
. - Your registry config must be
http://registry.npmjs.org
, or you can config it a Github npm registry byhttps://npm.pkg.github.com
.