deploy_feedback icon indicating copy to clipboard operation
deploy_feedback copied to clipboard

[Bug]: Can't authenticate NPM for private registry

Open ymoriaud opened this issue 11 months ago • 2 comments

Hello ! 👋

Problem description

Deno Deploy can't authenticate NPM with a private package registry/package. Deployment return a 401 error.

Context

In my Deno project, I added a private registry and private package using the .npmrc file. For this issue, let's call the private package private-package. The private registry is Github

.npmrc file:

@my-org:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}

The GITHUB_TOKEN env variable is stored in a .env file.

[!note] I tried to replace the env var by the the actual token but the issue is the same. I also tried to add the env variable in the Deno Deploy project settings, but still not working.

And I use this command to deploy the project: deployctl deploy --env-file=./.env

Error

Deno Deploy return this error during deployment : Error The deployment failed: HTTP status client error (401 Unauthorized) for url (https://npm.pkg.github.com/@my-org%2fprivate-package)

The local command deno install --reload --env-file=.env --entrypoint src/main.ts makes me believe that the token and configuration is correct, since deno install is able to install all dependencies, including the private ones. Of course, deno run --env-file=.env src/main.ts also works well.

Steps to reproduce

  1. Create a private package on Github
  2. Generate a Github classic token, with package:read permission
  3. Create a new folder
  4. Run deno init
  5. Create a .npmrc file in a Deno project (see above for .npmrc file example, you can write the token in the file for testing)
  6. Run deno add npm:@my-org/private-package
  7. Run deployctl deploy

You should have a 401 error.

Expected behavior

I expect Deno Deploy to be able to use the information in the .npmrc and use the authToken provided.

Environment

  • deno 2.2.1 (stable, release, aarch64-apple-darwin)
  • v8 13.4.114.9-rusty
  • typescript 5.7.3

Possible solution

No response

Additional context

No response

Please let me know if I'm wrong somewhere or if you need more details !

ymoriaud avatar Feb 21 '25 10:02 ymoriaud

Same issue here =\

hpandelo avatar Mar 12 '25 14:03 hpandelo

Also stuck with this issue :(

MAG-AdrianMeredith avatar Jul 21 '25 16:07 MAG-AdrianMeredith