To support basic authentication, edit your .npmrc
file and enter the following:
Your Artifactory username and password (formatted
username:password
) as Base64 encoded stringsYour email address (
npm publish
will not work if your email is not specified in.npmrc
)
.npmrc file location
Windows: %userprofile%\.npmrc
Linux: ~/.npmrc
Getting .npmrc entries directly from Artifactory
Run the following command to retrieve these strings directly from Artifactory:
$ curl -uadmin:<CREDENTIAL> http://<ARTIFACTORY_SERVER_DOMAIN>:8081/artifactory/api/npm/auth
Where <CREDENTIAL> is your Artifactory password or APIKey.
Here is an example of the response:
_auth = YWRtaW46e0RFU2VkZX1uOFRaaXh1Y0t3bHN4c2RCTVIwNjF3PT0= email = myemail@email.com always-auth = true
If, in addition, you are also working with scoped packages, you also need to run the following command:
curl -uadmin:<CREDENTIAL> http://<ARTIFACTORY_SERVER_DOMAIN>:8081/artifactory/api/npm/npm-repo/auth/<SCOPE>
Where <CREDENTIAL> is your Artifactory password or APIKey.
Paste the response to this command in the ~/.npmrc
file on your machine (in Windows, %USERPROFILE%/.npmrc
).