whenever i'm running Lerna bootstrap on Jenkins its fails with error, but passes on local machine.
npm ERR! code E401
npm ERR! Unable to authenticate, need: BASIC realm="Sonatype Nexus Repository Manager"
Package.json on main folder
"scripts":{
"bootstrap": "lerna bootstrap --loglevel verbose",
"publish-packages": "lerna publish --skip-git",
"clean": "lerna clean"
},
"dependencies": {
"lerna": "^5.0.0"
}
lerna.json
{
"packages": [
"packages/*"
],
"npmClientArgs": [
"--strict-ssl=false",
"--always-auth=true"
],
"version": "independent"
}
running commands
npm i
npm run bootstrap
npm i - passes but "npm run bootstrap" fails.
I've tried multiple options like
in .npmrc added credentials for my-repo
//my-repo-url:8081/nexus/repository/npm-repo/:_password=##base-64-encoded-password## //my-repo-url:8081/nexus/repository/npm-repo/:username=##usernamr##
in added in .npmrc _auth=##base-64-encoded-username-and-password##
added or removed "--always-auth=true" & "--strict-ssl" from "npmClientArgs" in lerna.json
Versions
- node v14.17.0
- npm 6.14.13
CodePudding user response:
Option#1
- I resolved by, adding "_auth" in lerna.json -> npmClientArgs.I Copied _auth value from .npmrc and added in "npmClientArgs"
- You can also generate authToken and use it here
{ "packages": [ "packages/*" ], "npmClientArgs": [ "--strict-ssl=false", "--always-auth=true", "--_auth=AUTH-KEY" ], "version": "independent" }
Option#2
- During build, you can recursively copy .npmrc in all "packages/*" folder