Onto-Med / top-frontend

JavaScript based frontend of the TOP Framework
MIT License
0 stars 1 forks source link

npm auth token yarn error #340

Closed KonradHoeffner closed 9 months ago

KonradHoeffner commented 9 months ago

I have exported my GitHub classic token to the NPM_AUTH_TOKEN environment variable but I get the following error with yarn:

frontend$ yarn
yarn install v1.22.21
error Error: Failed to replace env in config: ${NPM_AUTH_TOKEN}
    at /usr/lib/node_modules/yarn/lib/util/env-replace.js:19:13
    at String.replace (<anonymous>)
    at envReplace (/usr/lib/node_modules/yarn/lib/util/env-replace.js:14:16)
    at NpmRegistry.normalizeConfig (/usr/lib/node_modules/yarn/lib/registries/npm-registry.js:423:69)
    at /usr/lib/node_modules/yarn/lib/registries/npm-registry.js:455:36
    at Generator.next (<anonymous>)
    at step (/usr/lib/node_modules/yarn/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)
    at /usr/lib/node_modules/yarn/node_modules/babel-runtime/helpers/asyncToGenerator.js:28:13
KonradHoeffner commented 9 months ago

Does yarn ignore .npmrc? Update: No, I tried it without the braces and the error changes but still occurs. Creating an equivalent .yarnrc also does not help.

.yarnrc

  npmRegistryServer: "https://npm.pkg.github.com"
  npmAuthToken: ${NPM_AUTH_TOKEN}
ChristophB commented 9 months ago

Both .yarnrc and .npmrc are is working for me. Is your env var set correctly? BTW: There is a devcontainer setup in the .devcontainer folder to improve reproducibility.

KonradHoeffner commented 9 months ago

The variable is setup correctly but I also have a problem with the other login method:

22 verbose argv "login" "--scope" "@onto-med" "--auth-type" "legacy" "--registry" "https://npm.pkg.github.com"
23 timing npm:load:setTitle Completed in 1ms
24 timing npm:load:display Completed in 0ms
25 verbose logfile logs-max:10 dir:/home/konrad/.npm/_logs/2024-02-26T08_59_29_528Z-
26 verbose logfile /home/konrad/.npm/_logs/2024-02-26T08_59_29_528Z-debug-0.log
27 timing npm:load:logFile Completed in 6ms
28 timing npm:load:timers Completed in 0ms
29 timing npm:load:configScope Completed in 0ms
30 timing npm:load Completed in 21ms
31 notice Log in on https://npm.pkg.github.com/
32 silly logfile start cleaning logs, removing 1 files
33 silly logfile done cleaning log files
34 verbose login before first PUT {
34 verbose login   _id: 'org.couchdb.user:konradhoeffner',
34 verbose login   name: 'konradhoeffner',
34 verbose login   password: 'XXXXX',
34 verbose login   type: 'user',
34 verbose login   roles: [],
34 verbose login   date: '2024-02-26T08:59:33.890Z'
34 verbose login }
35 http fetch PUT 403 https://npm.pkg.github.com/-/user/org.couchdb.user:konradhoeffner 196ms
36 timing command:login Completed in 4516ms
37 verbose stack HttpErrorGeneral: 403 Forbidden - PUT https://npm.pkg.github.com/-/user/org.couchdb.user:konradhoeffner - Permission denied
37 verbose stack     at /usr/lib/node_modules/npm/node_modules/npm-registry-fetch/lib/check-response.js:95:15
37 verbose stack     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
37 verbose stack     at async otplease (/usr/lib/node_modules/npm/lib/utils/otplease.js:4:12)
37 verbose stack     at async Object.login (/usr/lib/node_modules/npm/lib/utils/auth.js:81:11)
37 verbose stack     at async Login.exec (/usr/lib/node_modules/npm/lib/commands/login.js:33:35)
37 verbose stack     at async module.exports (/usr/lib/node_modules/npm/lib/cli-entry.js:61:5)
38 verbose statusCode 403
39 verbose cwd /home/konrad/projekte/top/frontend
40 verbose Linux 6.7.4-arch1-1
41 verbose node v21.6.2
42 verbose npm  v10.4.0
43 error code E403
44 error 403 403 Forbidden - PUT https://npm.pkg.github.com/-/user/org.couchdb.user:konradhoeffner - Permission denied
45 error 403 In most cases, you or one of your dependencies are requesting
45 error 403 a package version that is forbidden by your security policy, or
45 error 403 on a server you do not have access to.
46 verbose exit 1

I will investigate this.

KonradHoeffner commented 9 months ago

Only occurs on my machine, seems to be user error.