npm-module-tutorial
v2.0.0
Published
An educational npm module demonstrating the fundamental steps of creating and publishing a Node.js package.
Maintainers
Readme
Steps to make npm package
- Signup https://www.npmjs.com/signup
- Decide npm package which is not available on npm registry and put as package-name in package.json
- create custom importable module
- npm init -y
- index.js
function helloNpmWorld() { return "hello NPM World" } module.exports = helloNpmWorld
Testing
npm linkto make package available globally- create test.js in test folder
const helloNpm = require('package-name') console.log(helloNpm()). npm link npm-module-tutorialwill create node_module and package-name in it.- run
node test.js
Publish npm package
npm loginnpm publish
rePublish npm package
- update Patch, Minor or Major version to republish
npm publish
Scoped npm package
npm init --scope=@your-username- package name
@your-username/package-name npm publish --access publicnpm publish --access private
Deprecate npm package
npm deprecate npm-module-tutorial@"< 2.0.0" "critical bug fixed in v2.0.0"- When will you try to install 1.0.0 npm will warn "npm warn deprecated [email protected]: critical bug fixed in v2.0.0" in terminal
