projen / projen

Rapidly build modern applications with advanced configuration management
https://projen.io
Apache License 2.0
2.53k stars 362 forks source link

Setting projenVersion attempts to pull projen from private npm registry #3642

Closed njdister closed 2 weeks ago

njdister commented 2 weeks ago

I'm trying to pin the version of projen in our AwsCdkConstructLibrary constructs. Once I add projenVersion to the construct configuration and run npx projen I get the following error:

error Error: https://<REDACTED>.d.codeartifact.us-east-1.amazonaws.com/npm/infrastructure-pypi-repo/projen: Unauthenticated: request did not include an Authorization header. Please provide your credentials.
    at params.callback [as _callback] (/Users/<REDACTED>/.cache/node/corepack/v1/yarn/1.22.22/lib/cli.js:66680:18)
    at self.callback (/Users/<REDACTED>/.cache/node/corepack/v1/yarn/1.22.22/lib/cli.js:141410:22)
    at Request.emit (node:events:517:28)
    at Request.<anonymous> (/Users/<REDACTED>/.cache/node/corepack/v1/yarn/1.22.22/lib/cli.js:142382:10)
    at Request.emit (node:events:517:28)
    at Gunzip.<anonymous> (/Users/<REDACTED>/.cache/node/corepack/v1/yarn/1.22.22/lib/cli.js:142304:12)
    at Object.onceWrapper (node:events:631:28)
    at Gunzip.emit (node:events:517:28)
    at endReadableNT (node:internal/streams/readable:1400:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
/Users/<REDACTED>/Dev/infrastructure-qa/node_modules/projen/src/task-runtime.ts:204
          throw new Error(
                ^
Error: Task "install" failed when executing "yarn install --check-files" (cwd: /Users/<REDACTED>/Dev/infrastructure-qa)
    at new RunTask (/Users/<REDACTED>/Dev/infrastructure-qa/node_modules/projen/src/task-runtime.ts:204:17)
    at TaskRuntime.runTask (/Users/<REDACTED>/Dev/infrastructure-qa/node_modules/projen/src/task-runtime.ts:76:5)
    at NodePackage.installDependencies (/Users/<REDACTED>/Dev/infrastructure-qa/node_modules/projen/src/javascript/node-package.ts:1551:13)
    at NodePackage.postSynthesize (/Users/<REDACTED>/Dev/infrastructure-qa/node_modules/projen/src/javascript/node-package.ts:898:12)
    at AwsCdkConstructLibrary.synth (/Users/<REDACTED>/Dev/infrastructure-qa/node_modules/projen/src/project.ts:624:14)
    at Object.<anonymous> (/Users/<REDACTED>/Dev/infrastructure-qa/.projenrc.ts:69:9)
    at Module._compile (node:internal/modules/cjs/loader:1364:14)
    at Module.m._compile (/Users/<REDACTED>/Dev/infrastructure-qa/node_modules/ts-node/src/index.ts:1618:23)
    at Module._extensions..js (node:internal/modules/cjs/loader:1422:10)
    at Object.require.extensions.<computed> [as .ts] (/Users/<REDACTED>/Dev/infrastructure-qa/node_modules/ts-node/src/index.ts:1621:12)

I don't understand why projen attempts to pull itself from our private registry only once its version is pinned. Are there any workarounds for this?

mrgrain commented 2 weeks ago

That sounds strange. What are you setting it to? What's the package.json look like after the change? Do you have an .npmrc file?

dkershner6 commented 2 weeks ago

Agree on .npmrc having a registry specified.

I will go one further and say it wasn't specified when you installed "latest" projen, and therefore is not pulling it from the private registry (cached, but otherwise would).

njdister commented 2 weeks ago

Agree on .npmrc having a registry specified.

I will go one further and say it wasn't specified when you installed "latest" projen, and therefore is not pulling it from the private registry (cached, but otherwise would).

Wow, turns out this was absolutely the problem. Our construct repos were fine, but I had this in my local ~/.npmrc. 🤦