Technology Sharing

Publishing npm packages

2024-07-12

한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina

Pre-release preparation

1. First check whether your npm source is an official mirror source. If not, switch to an official mirror source.

  1. // 官方镜像源
  2. npm config set registry https://registry.npmjs.org/
  3. // 如更换为淘宝镜像
  4. npm config set registry https://registry.npm.taobao.org/

2. Register an npm account

npm adduser

You can also go directly to the npm official website to register

3. Use npm login to log in to your account

npm login

Package

After logging in, use npm publish to publish the npm package

npm publish

Publish successful interface

Notice:

The name in package.json cannot be repeated, otherwise the package will fail to be sent and an error 403 will be reported.