In a few spots, docs/blog now recommend that you can set npm credentials using an environment variable1:
These recommend using the following syntax:
export "pnpm_config_//registry.npmjs.org/:_authToken=$NPM_TOKEN"
However, the above code snippet errors in bash or zsh (and I expect other shells), because they do not allow using setting environment variables with / or : or . in their name using this syntax.
Tangentially, the special characters in the environment variable name also seems to cause problems in GitHub Actions: pnpm/pnpm#12314 (comment)
While I think it is possible to set environment variables whose names have these characters using other tools (e.g. using the env utility or process.env in node), the fact that you can't do it with standard shell syntax makes the shell example in the docs kind of misleading and the feature hard to use in general.
Perhaps this caveat should be mentioned / the shell example should be removed / a more realistic example should be added. I think this might look like:
env "pnpm_config_//registry.npmjs.org/:_authToken=$NPM_TOKEN" pnpm install
(or, instead ofpnpm install, whatever pnpm command you want that uses auth)
In a few spots, docs/blog now recommend that you can set npm credentials using an environment variable1:
These recommend using the following syntax:
However, the above code snippet errors in bash or zsh (and I expect other shells), because they do not allow using setting environment variables with
/or:or.in their name using this syntax.Tangentially, the special characters in the environment variable name also seems to cause problems in GitHub Actions: pnpm/pnpm#12314 (comment)
While I think it is possible to set environment variables whose names have these characters using other tools (e.g. using the env utility or
process.envin node), the fact that you can't do it with standard shell syntax makes the shell example in the docs kind of misleading and the feature hard to use in general.Perhaps this caveat should be mentioned / the shell example should be removed / a more realistic example should be added. I think this might look like:
env "pnpm_config_//registry.npmjs.org/:_authToken=$NPM_TOKEN" pnpm install(or, instead of
pnpm install, whatever pnpm command you want that uses auth)Footnotes
New feature from https://github.com/pnpm/pnpm/pull/12338 ↩