简体   繁体   English

Lerna boostrap 因 npm ERR 而失败! 代码 E401

[英]Lerna boostrap fails with npm ERR! code E401

whenever i'm running Lerna bootstrap on Jenkins its fails with error, but passes on local machine.每当我在 Jenkins 上运行 Lerna 引导程序时,它都会因错误而失败,但会在本地机器上传递。

npm ERR! code E401
npm ERR! Unable to authenticate, need: BASIC realm="Sonatype Nexus Repository Manager"

Package.json on main folder主文件夹上的 Package.json

"scripts":{
  "bootstrap": "lerna bootstrap --loglevel verbose",
  "publish-packages": "lerna publish --skip-git",
  "clean": "lerna clean"
},
"dependencies": {
  "lerna": "^5.0.0"
}

lerna.json 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. npm i - 通过但“npm run bootstrap”失败。

I've tried multiple options like我尝试了多种选择,例如

  1. in .npmrc added credentials for my-repo在 .npmrc 中为 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## //my-repo-url:8081/nexus/repository/npm-repo/:_password=##base-64-encoded-password## //my-repo-url:8081/nexus/repository/npm-repo/ :username=##usernamr##

  2. in added in .npmrc _auth=##base-64-encoded-username-and-password##在 .npmrc 中添加 _auth=##base-64-encoded-username-and-password##

  3. added or removed "--always-auth=true" & "--strict-ssl" from "npmClientArgs" in lerna.json在 lerna.json 的“npmClientArgs”中添加或删除“--always-auth=true”和“--strict-ssl”

Versions版本

  1. node v14.17.0节点 v14.17.0
  2. npm 6.14.13 npm 6.14.13

Option#1选项1

  1. I resolved by, adding "_auth" in lerna.json -> npmClientArgs.I Copied _auth value from .npmrc and added in "npmClientArgs"我解决了,在 lerna.json -> npmClientArgs 中添加“_auth”。我从 .npmrc 复制 _auth 值并添加到“npmClientArgs”中
  2. You can also generate authToken and use it here你也可以在这里生成 authToken 并使用它
{ "packages": [ "packages/*" ], "npmClientArgs": [ "--strict-ssl=false", "--always-auth=true", "--_auth=AUTH-KEY" ], "version": "independent" }

Option#2选项#2

  1. During build, you can recursively copy .npmrc in all " packages/ *" folder在构建期间,您可以递归地将 .npmrc 复制到所有“ packages/ *”文件夹中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM