Recently, I took over the operation and maintenance work of an open source package within the previous department. I spent my spare time solving problems raised by developers, so I became familiar with the npm package release process, which is roughly as follows:
- Go to npm official website to register an account
- Package production:
1. Create the project directory
2. Open the command line window and execute the npm init command in the newly created project directory. Fill in the package related information as required.
npm login
If you encounter the following error:
npm ERR! network request to http://registry.cnpmjs.org/-/v1/login failed, reason: getaddrinfo ENOTFOUND registry.cnpmjs.org
Just do the following configuration directly on the command line
npm config set registry http://registry.npmjs.org/
Many developers may encounter prompts when publishing npm packages:
npm notice Beginning October 4, 2021, all connections to the npm registry - including for package installation - must use TLS 1.2 or higher. You are currently using plaintext http to connect. Please visit the GitHub blog for more information: https://github.blog/2021-08-23-npm-registry-deprecating-tls-1-0-tls-1-1/
That's because starting on October 4, 2021, all connections to the npm website and npm registry (including package installation) must use TLS 1.2 or higher.
You can use previous commands to install the relevant environment
npm install -g https://tls-test.npmjs.com/tls-test-1.0.0.tgz
After successful installation, the following content will be displayed
Hello! The tls-test package was successfully downloaded and installed.
Congratulations! Your package manager appears to support TLS 1.2.
[email protected]
added 1 package from 1 contributor in 3.718s
Then you can execute
npm login
npm publish
If the following is displayed, it means that the package has been successfully released. You can go to the npm official website to see the package you released.