DEV Community

Cover image for publlish a private npm package by using github packages

Posted on • Updated on

publlish a private npm package by using github packages


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.


  1. Create Your Personal Acess Token in github, plz select write packages and delete packages permission. Image description
  2. Login in github registry in your terminal, plz run npm login --scope=@OWNER --registry= this package is in your team, scope is your team's name.
  3. create a .npmrc file in your root dir, and add a line @OWNER:registry=
  4. 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 then the repository field should be git://
    • Verify the files field in your project's package.json. You should include files that should be published.
  5. publish package by running npm publish.
    Image description

How To Install

  1. You should follow HOW TO PUBLISH , and complete 1st step , 2nd step and 3rd step.
  2. run npm install @OWNER/your-components or yarn add @OWNER/your-components.

Top comments (0)