如何与Jenkins一起使用Github包注册表中的npm包?

如何与Jenkins一起使用Github包注册表中的npm包?,jenkins,github,npm,package,Jenkins,Github,Npm,Package,Jenkins无法从Github注册表中找到包,尽管获得了访问Github组织包的授权,并且名称空间在.npmrc和.yarnrc文件中命名 生成失败,出现以下错误: error An unexpected error occurred: "https://registry.npmjs.org/@git+https:%2f/****: Request \"https://registry.npmjs.org/@git+https:%2f/****\" returned a 405". error

Jenkins无法从Github注册表中找到包,尽管获得了访问Github组织包的授权,并且名称空间在
.npmrc
.yarnrc
文件中命名

生成失败,出现以下错误:

error An unexpected error occurred: "https://registry.npmjs.org/@git+https:%2f/****: Request \"https://registry.npmjs.org/@git+https:%2f/****\" returned a 405".
error Couldn't find package "@git+https://****" on the "npm" registry.

Jenkins似乎只在npm的注册表中查找包,而忽略npmrc文件。Jenkins文档似乎没有提到Github包。有人能给我指出正确的方向吗?

您需要在您的文件中使用下面的设置注册表

npm config set registry https://registry.foo.bar.com 
或者直接发布安装,如下所示

npm install --registry https://registry.foo.bar.com
Jenkins文件阶段示例:

     stage('NPM Installation') {
          steps {
              container('nodejs) {
                sh '''
                  npm install --registry=https://registry.foo.bar.com
               '''
            }
          }
        }

如果您试图对您的私有github软件包进行身份验证,请按照此处列出的步骤操作-->

抱歉,现在才看到您的响应!不过,我们在那里只托管了某些包,所有其他包仍然应该来自npmjs.org。@Jacob 1。您可以尝试npm的范围包。您可以在发布和安装这些包时使用作用域对其进行作用域设置。2.为您拥有的不同npm注册表设置别名&在安装npm之前设置别名。或者npm安装--registry=您的私有注册表,npm安装--registry=您的公共注册表。