Created
April 11, 2021 21:41
-
-
Save cristobal/73ac9ebefec3f652d9a5d35737011134 to your computer and use it in GitHub Desktop.
Setting custom NPM_USER_CONFIG with readonly NPM_TOKEN via Powershell (Tested in TeamCity)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Write NPM_TOKEN registry without BOM @see https://stackoverflow.com/a/32951824 | |
[IO.File]::WriteAllLines("$(Get-Location)\.npmrc", "//registry.npmjs.org/:_authToken=$env:NPM_TOKEN") | |
# Set Custom NPM_CONFIG_USERCONFIG Environment variable | |
$env:NPM_CONFIG_USERCONFIG="$(Get-Location)\.npmrc" | |
# debug who you are | |
# npm whoami | |
# replace * with the npm script you want to run. | |
npm run * | |
# Remove Custom NPM_CONFIG_USERCONFIG Environment variable | |
Remove-Item Env:NPM_CONFIG_USERCONFIG |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment