Search code examples
githubnpmgithub-package-registry

GitHub Package Registry NPM 400 Put Error


Sometimes it's possible to get an error like the following when trying to publish your NPM package to GitHub Package Registry using npm publish:

npm ERR! code E400
npm ERR! 400 Bad Request - PUT https://npm.pkg.github.com/@myorg%2fmypackage - RepoAcceptsPackageUploads: Repository "myorg/mypackage" does not exist.

Solution

  • According to the GitHub documentation for authenticating with GitHub Package Registry if the repository that you are trying to publish the package to is a private repo, the personal access token that you authenticate with must have the following scopes:

    • read:packages
    • write:packages
    • repo

    In this case the repo scope was the one missing since it wasn't immediately clear that scope was needed to publish packages to private repos.