[Bug]: Can't authenticate NPM for private registry
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
- Create a private package on Github
- Generate a Github classic token, with
package:readpermission - Create a new folder
- Run
deno init - Create a
.npmrcfile in a Deno project (see above for .npmrc file example, you can write the token in the file for testing) - Run
deno add npm:@my-org/private-package - 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 !
Same issue here =\
Also stuck with this issue :(