1.0.2 • Published 5 years ago
node-module-example-of-thsi v1.0.2
Node-Module-Example
1. Create package.json
npm initNote: define your module name in name field of package.json.
2. Define a entry file
entry is a file that return object method for the require('your_module_name') call.
Can be config in main field of package.json
3. login your npm account
npm login
npm whoami4. Publish your module
npm publish5. Install and Use your module
# Anthor directory
npm install your-package-nameconst myModule = require('your-package-name');
myModule();Notice:
- 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.