Initialize the project
#New Folder
mkdir whosmeya-npm-package-test
#Enter the
cd whosmeya-npm-package-test/
#Initialize package.json, -y to use the default configuration
npm init -y
#The new file
touch index.js
Copy the code
Write the following code in index.js
exports.test = 'Hello world! ';
Copy the code
Directory as follows
Register an NPM account
Register the NPM account at www.npmjs.com/login
After registration, remember to verify email (if the verification fails, copy the verification address to the browser of the registered account to open), if not verified, the release will be 403.
landing
npm login
Copy the code
release
npm publish
Copy the code
Release success, NPM official website view
use
npm install whosmeya-npm-package-test
Copy the code
import { test } from 'whosmeya-npm-package-test';
console.log(test);
// Hello world!
Copy the code
An updated version
Modify the package. The json
- "version" : "1.0.0",
+ "version" : "1.0.1,"
Copy the code
release
npm publish
Copy the code
The version number of the NPM package has also been changed to 1.0.1
Associated GitHub publication
npm version patch && git push --follow-tags && npm publish
npm version minor && git push --follow-tags && npm publish
npm version major && git push --follow-tags && npm publish
Copy the code
This increments the package version number, commits the change, then creates a local tag, pushes it to Github and publishes it to the NPM package.
You can then go to github’s publishing page and write Changelog for the new TAB.
Next article: Developing a robust NPM package