How to set _authToken via pnpmCommand?
I'm looking for a way to do something like this. Does anyone know how I could set the token? I do not want to set it via project's .npmrc. Thank you!
pnpmCommand.set(listOf("config set https://npm.pkg.github.com/:_authToken $authToken"))
Based on the constraints I'd recommend using an environment variable https://pnpm.io/npmrc#url_authtoken https://github.com/pnpm/pnpm/issues/3141#issuecomment-1279842014
Thanks you for your reply!
i've tried two things, setting it the env with gradle.
val buildFrontend by tasks.registering(PnpmTask::class) {
val version = project.property("version")
environment.set(
mapOf(
"VITE_MY_VERSION" to version.toString(),
"npm_config_//npm.pkg.github.com/:_authtoken" to authToken.toString()
)
)
pnpmCommand.set(listOf("build:web"))
dependsOn(tasks.pnpmInstall)
it still errors out on install with 401
> Task :frontend:pnpmInstall
Progress: resolved 0, reused 1, downloaded 0, added 0
ERR_PNPM_FETCH_401 GET https://npm.pkg.github.com/some-pkg: Unauthorized - 401
and setting it directly in bash
$ export npm_config_//npm.pkg.github.com/:_authtoken=myToken
export: not valid in this context: npm_config_//npm.pkg.github.com/:_authtoken
this errors out with not valid because of all the special chars like . and / right?
It looks like that the env example is only working for github actions? I'm running this on jenkins