首页 > 解决方案 > AWS CodePipeline 不适用于 Github NPM 包?

问题描述

我有一个从库中使用的 Angular webapp,该库同时作为私有 npm 包发布到 github 存储库。现在我的库项目 package.json 看起来像这样:

{
  "name": "@tihomir22/generales-wrapper-lib",
  "version": "0.0.11",
  "peerDependencies": {
    "@angular/animations": "~11.1.2",
    "@angular/cdk": "~11.1.1-sha-fdacb22f2",
    "@angular/common": "~11.1.2",
    "@angular/compiler": "~11.1.2",
    "@angular/core": "~11.1.2",
    "@angular/forms": "~11.1.2",
    "@angular/material": "~11.1.1-sha-fdacb22f2",
    "@angular/platform-browser": "~11.1.2",
    "@angular/platform-browser-dynamic": "~11.1.2",
    "@angular/router": "~11.1.2"
  },
  "dependencies": {
    "@m0t0r/ngx-slider": "^1.0.0",
    "animejs": "^3.2.0",
    "lodash-es": "^4.17.20",
    "material-icons": "^0.5.3",
    "ngx-cookie-service": "latest",
    "tslib": "^2.0.0",
    "uuid": "^8.3.1"
  },
  "devDependencies": {
    "@types/uuid": "^8.3.0",
    "@types/lodash-es": "latest"
  },
  "publishConfig": {
    "registry": "https://npm.pkg.github.com/"
  }
}

我也有这个项目的 .npmrc 文件本地化:

`//npm.pkg.github.com/:_authToken=PRIVATE_TOKEN

在消费者项目中,我将库作为典型的 npm 包:

 "@tihomir22/generales-wrapper-lib": "0.0.11",

我的主目录中还有另一个 .npmrc,配置如下:

 @tihomir22:registry=https://npm.pkg.github.com/
//npm.pkg.github.com/:_authToken=SECRET TOKEN

现在,棘手的事情来了,当我在本地安装它时,它安装没有任何问题并且一切顺利,但是,当我尝试通过 aws codepipeline 编译它时,它说我找不到 404 =/:

npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/@tihomir22%2fgenerales-wrapper-lib - Not found
npm ERR! 404 
npm ERR! 404  '@tihomir22/generales-wrapper-lib@0.0.11' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404 It was specified as a dependency of 'src'
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2021-02-21T20_18_56_261Z-debug.log

您可能已经注意到,它试图在不同的注册表上找到它,我猜是因为代码管道 dosnt 有这个 .npmrc 文件会更改注册表,所以我添加了消费者项目本身。但后来它给了我 401 Unauthorized。

我忘了做什么?AWS 需要做什么?

提前致谢!

标签: node.jsangularamazon-web-servicesnpm

解决方案


推荐阅读