Open AllySummers opened 1 week ago
I'm having a similar issue when trying to use with a conventional package.json
containing dependencies on (e.g.) @myorg/package
(hosted on Azure DevOps artifacts) with .npmrc
of (similarly obfuscated):
registry=https://pkgs.dev.azure.com/myorg/_packaging/team/npm/registry/
always-auth=true
; begin auth token
//pkgs.dev.azure.com/myorg/_packaging/team/npm/registry/:username=myorg
//pkgs.dev.azure.com/myorg/_packaging/team/npm/registry/:_password={base64token}
//pkgs.dev.azure.com/myorg/_packaging/team/npm/registry/:email=npm requires email to be set but doesn't use the value
//pkgs.dev.azure.com/myorg/_packaging/team/npm/:username=myorg
//pkgs.dev.azure.com/myorg/_packaging/team/npm/:_password={base64token}
//pkgs.dev.azure.com/myorg/_packaging/team/npm/:email=npm requires email to be set but doesn't use the value
; end auth token
This is a single .npmrc
in the project root (same dir as package.json
). deno install
gives the following response as part of the 401 error, which suggests it isn't passing the username correctly:
{"$id":"1","innerException":null,"message":"TF400813: The user 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' is not authorized to access this resource.","typeName":"Microsoft.TeamFoundation.Framework.Server.UnauthorizedRequestException, Microsoft.TeamFoundation.Framework.Server","typeKey":"UnauthorizedRequestException","errorCode":0,"eventId":3000}
Edit: This was from the stable 2.0.0 version of deno and npm install
works without issue
Directed here from this Discord thread: Deno > #help > deno gives 401 unauthorized for imports with an
npm:
specifier, but npm, yarn and pnpm all workTested Deno Versions (all same result):
7b509e492ed6c7ace0f3860c3f4e8e7be3452fda
(canary)v2.0.0-rc.10
v1.46.3
(stable)When attempting to import anything using an
npm:
specifier, either in a typescript file or on the CLI, I get the following error:This happens regardless of if I'm running a package from the CLI, i.e.:
or if I'm trying to import from something in a script, i.e.:
(just using angular as an example here, it happens with every single package I tried it with, whether that was an unscoped public package, a public scoped package, or private scoped package)
If I rename/delete the
.npmrc
in my home directory and try running the exact same thing, it works perfectly fine. Only my npmrc seems to be the issue?In the below files/logs/configs, I've replaced all instances of my username with
myusername
, all instances of my company's name withmycompany
, and if applicable, replaced the IP address(es) and replaced my password withmypassword
.Results of ` RUST_BACKTRACE=1 DENO_LOG=debug deno run -A npm:@angular/cli`
```shell ~ RUST_BACKTRACE=1 DENO_LOG=debug deno run -A npm:@angular/cli DEBUG RS - deno::args:932 - Finished config loading. DEBUG RS - deno::cache::cache_db:168 - Opening cache /Users/myusername/Library/Caches/deno/dep_analysis_cache_v2... DEBUG RS - deno::cache::cache_db:168 - Opening cache /Users/myusername/Library/Caches/deno/node_analysis_cache_v2... DEBUG RS - deno::cache::cache_db:168 - Opening cache /Users/myusername/Library/Caches/deno/v8_code_cache_v2... DEBUG RS - deno::npm::managed::resolution:282 - Running npm resolution. DEBUG RS - hyper_util::client::legacy::connect::dns:122 - resolving host="packages.mycompany.com" DEBUG RS - hyper_util::client::legacy::connect::http:643 - connecting to 123.123.123.123:443 DEBUG RS - hyper_util::client::legacy::connect::http:646 - connected to 456.456.456.456:443 DEBUG RS - h2::client:1281 - binding client connection DEBUG RS - h2::client:1286 - client connection bound DEBUG RS - h2::codec::framed_write:213 - send frame=Settings { flags: (0x0), enable_push: 0, initial_window_size: 2097152, max_frame_size: 16384, max_header_list_size: 16384 } DEBUG RS - h2::proto::connection:138 - Connection; peer=Client DEBUG RS - hyper_util::client::legacy::pool:396 - pooling idle connection for ("https", packages.mycompany.com) DEBUG RS - h2::codec::framed_write:213 - send frame=WindowUpdate { stream_id: StreamId(0), size_increment: 5177345 } DEBUG RS - h2::codec::framed_write:213 - send frame=Headers { stream_id: StreamId(1), flags: (0x5: END_HEADERS | END_STREAM) } DEBUG RS - h2::codec::framed_read:405 - received frame=Settings { flags: (0x0), max_concurrent_streams: 128, initial_window_size: 65536, max_frame_size: 16777215 } DEBUG RS - h2::codec::framed_write:213 - send frame=Settings { flags: (0x1: ACK) } DEBUG RS - h2::codec::framed_read:405 - received frame=WindowUpdate { stream_id: StreamId(0), size_increment: 2147418112 } DEBUG RS - h2::codec::framed_read:405 - received frame=Settings { flags: (0x1: ACK) } DEBUG RS - h2::proto::settings:56 - received settings ACK; applying Settings { flags: (0x0), enable_push: 0, initial_window_size: 2097152, max_frame_size: 16384, max_header_list_size: 16384 } DEBUG RS - h2::codec::framed_read:405 - received frame=Headers { stream_id: StreamId(1), flags: (0x4: END_HEADERS) } DEBUG RS - h2::codec::framed_read:405 - received frame=Data { stream_id: StreamId(1) } DEBUG RS - h2::codec::framed_read:405 - received frame=Data { stream_id: StreamId(1), flags: (0x1: END_STREAM) } DEBUG RS - h2::codec::framed_write:213 - send frame=GoAway { error_code: NO_ERROR, last_stream_id: StreamId(0) } DEBUG RS - h2::proto::connection:428 - Connection::poll; connection error error=GoAway(b"", NO_ERROR, Library) error: Error getting response at https://packages.mycompany.com/artifactory/api/npm/npm-remote/@angular/cli%25C2%25A0 for package "@angular/cli%C2%A0": Bad response: 401 { "errors" : [ { "status" : 401, "message" : "Bad credentials" } ] } Stack backtrace: 0: std::backtrace::Backtrace::capture 1: anyhow::error::My `~/.npmrc` (npmrc in home directory)
``` registry=https://packages.mycompany.com/artifactory/api/npm/npm-remote @mycompanysox:registry=https://packages.mycompany.com/artifactory/api/npm/mycompany-npm/ @fortawesome:registry=https://packages.mycompany.com/artifactory/api/npm/npm-remote-fontawesome/ @mycompany:registry=https://packages.mycompany.com/artifactory/api/npm/mycompany-npm/ //packages.mycompany.com/artifactory/api/npm/mycompany-npm/:_password=mypassword //packages.mycompany.com/artifactory/api/npm/mycompany-npm/:username=myusername //packages.mycompany.com/artifactory/api/npm/mycompany-npm/:email=myusername@mycompany.com //packages.mycompany.com/artifactory/api/npm/mycompany-npm/:always-auth=true //packages.mycompany.com/api/npm/mycompany-npm/:_password=mypassword //packages.mycompany.com/api/npm/mycompany-npm/:username=myusername //packages.mycompany.com/api/npm/mycompany-npm/:email=myusername@mycompany.com //packages.mycompany.com/api/npm/mycompany-npm/:always-auth=true //packages.mycompany.com/artifactory/api/npm/npm-remote-fontawesome/:_password=mypassword //packages.mycompany.com/artifactory/api/npm/npm-remote-fontawesome/:username=myusername //packages.mycompany.com/artifactory/api/npm/npm-remote-fontawesome/:email=myusername@mycompany.com //packages.mycompany.com/artifactory/api/npm/npm-remote-fontawesome/:always-auth=true //packages.mycompany.com/api/npm/npm-remote-fontawesome/:_password=mypassword //packages.mycompany.com/api/npm/npm-remote-fontawesome/:username=myusername //packages.mycompany.com/api/npm/npm-remote-fontawesome/:email=myusername@mycompany.com //packages.mycompany.com/api/npm/npm-remote-fontawesome/:always-auth=true //packages.mycompany.com/artifactory/api/npm/npm-remote-fontawesome/:_password=mypassword //packages.mycompany.com/artifactory/api/npm/npm-remote-fontawesome/:username=myusername //packages.mycompany.com/artifactory/api/npm/npm-remote-fontawesome/:email=myusername@mycompany.com //packages.mycompany.com/artifactory/api/npm/npm-remote-fontawesome/:always-auth=true //packages.mycompany.com/api/npm/npm-remote-fontawesome/:_password=mypassword //packages.mycompany.com/api/npm/npm-remote-fontawesome/:username=myusername //packages.mycompany.com/api/npm/npm-remote-fontawesome/:email=myusername@mycompany.com //packages.mycompany.com/api/npm/npm-remote-fontawesome/:always-auth=true //packages.mycompany.com/artifactory/api/npm/npm-remote/:_password=mypassword //packages.mycompany.com/artifactory/api/npm/npm-remote/:username=myusername //packages.mycompany.com/artifactory/api/npm/npm-remote/:email=myusername@mycompany.com //packages.mycompany.com/artifactory/api/npm/npm-remote/:always-auth=true //packages.mycompany.com/api/npm/npm-remote/:_password=mypassword //packages.mycompany.com/api/npm/npm-remote/:username=myusername //packages.mycompany.com/api/npm/npm-remote/:email=myusername@mycompany.com //packages.mycompany.com/api/npm/npm-remote/:always-auth=true ```Results of `npm config list --json --long` (I believe this shows the fully resolved/active config)
```json { "json": true, "long": true, "registry": "https://packages.mycompany.com/artifactory/api/npm/npm-remote", "@mycompanysox:registry": "https://packages.mycompany.com/artifactory/api/npm/mycompany-npm/", "@fortawesome:registry": "https://packages.mycompany.com/artifactory/api/npm/npm-remote-fontawesome/", "@mycompany:registry": "https://packages.mycompany.com/artifactory/api/npm/mycompany-npm/", "//packages.mycompany.com/artifactory/api/npm/mycompany-npm/:username": "myusername", "//packages.mycompany.com/artifactory/api/npm/mycompany-npm/:email": "myusername@mycompany.com", "//packages.mycompany.com/artifactory/api/npm/mycompany-npm/:always-auth": true, "//packages.mycompany.com/api/npm/mycompany-npm/:username": "myusername", "//packages.mycompany.com/api/npm/mycompany-npm/:email": "myusername@mycompany.com", "//packages.mycompany.com/api/npm/mycompany-npm/:always-auth": true, "//packages.mycompany.com/artifactory/api/npm/npm-remote-fontawesome/:username": "myusername", "//packages.mycompany.com/artifactory/api/npm/npm-remote-fontawesome/:email": "myusername@mycompany.com", "//packages.mycompany.com/artifactory/api/npm/npm-remote-fontawesome/:always-auth": true, "//packages.mycompany.com/api/npm/npm-remote-fontawesome/:username": "myusername", "//packages.mycompany.com/api/npm/npm-remote-fontawesome/:email": "myusername@mycompany.com", "//packages.mycompany.com/api/npm/npm-remote-fontawesome/:always-auth": true, "//packages.mycompany.com/artifactory/api/npm/npm-remote/:username": "myusername", "//packages.mycompany.com/artifactory/api/npm/npm-remote/:email": "myusername@mycompany.com", "//packages.mycompany.com/artifactory/api/npm/npm-remote/:always-auth": true, "//packages.mycompany.com/api/npm/npm-remote/:username": "myusername", "//packages.mycompany.com/api/npm/npm-remote/:email": "myusername@mycompany.com", "//packages.mycompany.com/api/npm/npm-remote/:always-auth": true, "access": null, "all": false, "allow-same-version": false, "also": null, "audit": true, "audit-level": null, "auth-type": "web", "before": null, "bin-links": true, "browser": null, "ca": null, "cache": "/Users/myusername/.npm", "cache-max": null, "cache-min": 0, "cafile": null, "call": "", "cert": null, "cidr": null, "color": true, "commit-hooks": true, "cpu": null, "os": null, "libc": null, "depth": null, "description": true, "dev": false, "diff": [], "diff-ignore-all-space": false, "diff-name-only": false, "diff-no-prefix": false, "diff-dst-prefix": "b/", "diff-src-prefix": "a/", "diff-text": false, "diff-unified": 3, "dry-run": false, "editor": "hx", "engine-strict": false, "expect-results": null, "expect-result-count": null, "fetch-retries": 2, "fetch-retry-factor": 10, "fetch-retry-maxtimeout": 60000, "fetch-retry-mintimeout": 10000, "fetch-timeout": 300000, "force": false, "foreground-scripts": false, "format-package-lock": true, "fund": true, "git": "git", "git-tag-version": true, "global": false, "globalconfig": "/Users/myusername/.nvm/versions/node/v18.20.1/etc/npmrc", "global-style": false, "heading": "npm", "https-proxy": null, "if-present": false, "ignore-scripts": false, "include": [], "include-staged": false, "include-workspace-root": false, "init-author-email": "", "init-author-name": "", "init-author-url": "", "init-license": "ISC", "init-module": "/Users/myusername/.npm-init.js", "init-version": "1.0.0", "init.author.email": "", "init.author.name": "", "init.author.url": "", "init.license": "ISC", "init.module": "/Users/myusername/.npm-init.js", "init.version": "1.0.0", "install-links": false, "install-strategy": "hoisted", "key": null, "legacy-bundling": false, "legacy-peer-deps": false, "link": false, "local-address": null, "sbom-format": null, "sbom-type": "library", "location": "user", "lockfile-version": null, "loglevel": "notice", "logs-dir": null, "logs-max": 10, "maxsockets": 15, "message": "%s", "node-options": null, "noproxy": [ "" ], "offline": false, "omit": [], "omit-lockfile-registry-resolved": false, "only": null, "optional": null, "otp": null, "package": [], "package-lock": true, "package-lock-only": false, "pack-destination": ".", "parseable": false, "prefer-dedupe": false, "prefer-offline": false, "prefer-online": false, "prefix": "/Users/myusername/.nvm/versions/node/v18.20.1", "preid": "", "production": null, "progress": true, "provenance": false, "provenance-file": null, "proxy": null, "read-only": false, "rebuild-bundle": true, "replace-registry-host": "npmjs", "save": true, "save-bundle": false, "save-dev": false, "save-exact": false, "save-optional": false, "save-peer": false, "save-prefix": "^", "save-prod": false, "scope": "", "script-shell": null, "searchexclude": "", "searchlimit": 20, "searchopts": "", "searchstaleness": 900, "shell": "/bin/zsh", "shrinkwrap": true, "sign-git-commit": false, "sign-git-tag": false, "strict-peer-deps": false, "strict-ssl": true, "tag": "latest", "tag-version-prefix": "v", "timing": false, "umask": 0, "unicode": true, "update-notifier": true, "usage": false, "user-agent": "npm/{npm-version} node/{node-version} {platform} {arch} workspaces/{workspaces} {ci}", "userconfig": "/Users/myusername/.npmrc", "version": false, "versions": false, "viewer": "man", "which": null, "workspace": [], "workspaces": null, "workspaces-update": true, "yes": null, "npm-version": "10.5.0" } ```Output of `yarn config --json | jq -s '.'` (similar command for yarn, and converting newline-delimited json to a json array)
```json [ { "key": "cacheFolder", "effective": "/Users/myusername/.yarn/berry/cache", "source": "