Skip to content

pluswhite/Node-Module-Example

Repository files navigation

Node-Module-Example

npm GitHub npm

1. Create package.json

npm init

Note: 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 whoami

4. Publish your module

npm publish

5. Install and Use your module

# Anthor directory
npm install your-package-name
const myModule = require('your-package-name');
myModule();

Notice:

  1. 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.
  2. 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.
  3. Your registry config must be http://registry.npmjs.org, or you can config it a Github npm registry by https://npm.pkg.github.com.

About

Example of node module, with TypeScript, Jest, ESLint, Prettier.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •