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.
Your Personal Acess Tokenin github, plz select
write 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
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
- Verify the files field in your project's package.json. You should include files that should be published.
- You should follow HOW TO PUBLISH , and complete 1st step , 2nd step and 3rd step.
npm install @OWNER/your-componentsor
yarn add @OWNER/your-components.