The steps to create an npm image bed are as follows




1.Register npm account
https://www.npmjs.com/



  1. Obtain token : Log in to npm, click the avatar in the upper right corner to enter Access Token. Click Generate New Token and select Classic Token. Check Automation and click Generate Token to generate the token. Save the generated token.


  1. Create a GitHub repository: You need a GitHub account and an already created repository with any name and permissions that can be private or public.


  1. Add variables: Select Settings in the GitHub repository and select Actions in Secrets. Click New repository secret to add a new Secret. Fill in NPM_TOKEN for Name, and fill in the npm token obtained previously for Secret.


5.On github, find the image repository we created before and clone it in a suitable local location. Find an empty folder, open the terminal and enter
git clone git@github.com:[username]/[your repository].git
#or
git clone https://github.com/[username]/[your repository].git



  1. Open the terminal in the [warehouse] folder that was cloned, and enter the following command to switch back to the original source.
    npm config set registry https://registry.npmjs.org


  1. Add local npm user settings

    Only the first time you need to add a user, you will be prompted to enter your npm account password and registered email address.

    npm adduser

    If you are not using it for the first time, you can log in directly. You will be prompted to enter your npm account password and registered email address.

    npm login


  1. Run the npm initialization command, package the entire image bed warehouse, and configure it according to the instructions. Note that you need to confirm in advance that your package name does not duplicate the package published by others. You can search for the corresponding package name on the npm official website. If you cannot find it, please explain. Not occupied yet.
    npm init


  1. Then enter the release command, and we can publish the package to npm.
    npm publish


  1. Add the image file you want to upload to the project folder (the local warehouse cloned in step 6).


  1. Open the terminal under the local [Clone Warehouse] folder, run the following instructions, and upload the new content to github to trigger deployment.

    Submit changes

    git add .
    git commit -m “npm publish”

    Update package version number

    npm version patch

    Push to github to trigger action

    git push


{The four lines of instructions here are in strict order.
Every time you update the npm image bed, you need to modify the version in [Local Warehouse]\package.json, which is the version number.
npm version patch is an instruction to update the version number in package.json. The effect is that the last version number is +1, for example, 0.0.1=>0.0.2, 1.1.3=>1.1.4. It eliminates the trouble of opening package.json and modifying the version number. (Major version updates still require manual changes)
When updating npm images, be sure to update the version number in package.json! }



G仓图片


Author: Qin hao
Reprint policy: All articles in this blog are used except for special statements CC BY 4.0 reprint polocy. If reproduced, please indicate source Qin hao !
Reward
  TOC
chatsimple