BACKGROUND
Sometimes we need publish NPM package for reusing code, and we don’t want stranger to access our package,so we need publish a private npm package.
HOW TO PUBLISH
- Create
Your Personal Acess Token
in github, plz selectwrite packages and delete packages permission
. - Login in github registry in your terminal, plz
run npm login --scope=@OWNER --registry=https://npm.pkg.github.com
.If this package is in your team, scope is your team's name. - create a .npmrc file in your root dir, and add a line
@OWNER:registry=https://npm.pkg.github.com
. -
modify package.json file
- Verify the name of your package in your project's package.json. The name field must contain the scope and the name of the package. For example, if your package is called "test", and you are publishing to the "My-org" GitHub organization, the name field in your package.json should be @my-org/test.
- Verify the repository field in your project's package.json. The repository field must match the URL for your GitHub repository. For example, if your repository URL is github.com/my-org/test then the repository field should be
git://github.com/my-org/test.git
. - Verify the files field in your project's package.json. You should include files that should be published.
How To Install
- You should follow HOW TO PUBLISH , and complete 1st step , 2nd step and 3rd step.
- run
npm install @OWNER/your-components
oryarn add @OWNER/your-components
.
Top comments (0)