This question includes a specific use-case:
@myscope/mypackage
https://company.jfrog.io/artifactory/api/npm/my-npm-registry/
How can I do that?
.npmrc
First, you need to configure your access in a local .npmrc
file. You can put this file in your source root folder.
always-auth = true
# First, set a different registry URL for your scope
@myscope:registry=https://company.jfrog.io/artifactory/api/npm/my-npm-registry/
# Then, for this scope, you need to set the token
//company.jfrog.io/artifactory/api/npm/my-npm-registry/:_auth = {{your token - see below}}
You need to get the NPM Token from Artifactory (note it isn't your API Key.
curl -u {{ ARTIFACTORY_USERNAME }}:{{ ARTIFACTORY_API_KEY }} https://company.jfrog.io/artifactory/api/npm/auth/
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f {{ ARTIFACTORY_USERNAME }},{{ ARTIFACTORY_API_KEY }}))) Invoke-RestMethod -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)} https://company.jfrog.io/artifactory/api/npm/auth/
_auth = {{ YOUR_NPM_TOKEN }} always-auth = true
.npmrc
file above.How to do all this in Github Actions?
JFROG_USER
& JFROG_PAT
.yarn/npm install
: - name: npm token run: | echo "@myscope:registry=https://company.jfrog.io/artifactory/api/npm/my-npm-registry/" >.npmrc echo "//company.jfrog.io/artifactory/api/npm/my-npm-registry/:$(curl -u ${{ secrets.JFROG_USER }}:${{ secrets.JFROG_PAT }} https://company.jfrog.io/artifactory/api/npm/auth/)" >>.npmrc
GOOD LUCK!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.