First you have to register an NPM account on the official website

For example, let’s create a new index.js file that just prints one sentence, and publish the file as an NPM package

Initialize the

npm init

Doing this generates a package.json file locally and enters the corresponding description version number and so on as prompted.

{
  "name": "charllote-bao"."version": "1.0.0"."description": "test"."main": "index.js"."scripts": {
    "test": "npm install charllote "
  },
  "author": "charllote"."license": "ISC"
}
Copy the code

Log in to your NPM account

npm login

Release operation

npm publish

If you encounter the following error message, it means that you may not have to verify your email after registering, open your bound email, click the verification link of NPM.

npm ERR! code E403
npm ERR! 403 Forbidden - PUT https://registry.npmjs.org/charllote-bao - you must verify your email before publishing a new package: https://www.npmjs.com/email-edit

Copy the code

The newly released package can be seen on your NPM home page after successful publication

The update operation

NPM version patch // This operation will +1 NPM publish // republish on the previous version numberCopy the code

After successful execution, you will see a newly released version package on the home page

Delete operation

Deletes the specified package and version number

NPM unpublish package name @version numberCopy the code