首页 > 解决方案 > 在 Azure DevOps 源上添加其他 npm 包

问题描述

我为我的项目使用 Angular 2.4,并且该项目包含.npmrc使用内部寄存器的文件。目前构建管道正在返回此错误:

找不到与 yargs@^3.32.0 匹配的版本。在大多数情况下,您或您的依赖项之一正在请求一个不存在的包版本。

我的项目正在使用uglify-jsnpm 包,而yargsnpm 包是它的依赖项之一。因此,我在 package.json 中添加了yargsanduglify-js以查看它是否会使 Azure DevOp 构建中的错误消失,但事实并非如此。

这是 package.json:

{
  "name": "xxx",
  "version": "1.5.3",
  "private": true,
  "dependencies": {
    "@angular/common": "~2.4.0",
    "@angular/compiler": "~2.4.0",
    "@angular/core": "~2.4.0",
    "@angular/forms": "~2.4.0",
    "@angular/http": "~2.4.0",
    "@angular/platform-browser": "~2.4.0",
    "@angular/platform-browser-dynamic": "~2.4.0",
    "@angular/router": "~3.4.0",
    "@microsoft/1ds-analytics-web-js": "^3.1.6",
    "@microsoft/1ds-properties-js": "^3.1.6",
    "aspnet-webpack": "^1.0.29",
    "core-js": "^2.4.1",
    "hammerjs": "^2.0.8",
    "moment": "2.17.*",
    "ng2-translate": "~5.0.0",
    "ngx-infinite-scroll": "~0.8.2",
    "reflect-metadata": "^0.1.8",
    "rxjs": "~5.5.6",
    "webpack-hot-middleware": "^2.18.0",
    "zone.js": "^0.7.4"
  },
  "devDependencies": {
    "css-loader": "^0.23.1",
    "del": "^2.2.2",
    "extendify": "^1.0.0",
    "extract-text-webpack-plugin": "^1.0.1",
    "file-loader": "^0.8.5",
    "gulp": "^3.9.1",
    "jquery": "^2.2.3",
    "raw-loader": "^0.5.1",
    "style-loader": "^0.13.1",
    "ts-loader": "5.4.5",
    "tslint": "^3.8.1",
    "typescript": "4.2.4",
    "url-loader": "^0.5.7",
    "webpack": "^1.13.0",
    "yargs": "^3.32.0",
    "uglify-js": "^2.8.28"
  }
}

但是,我在构建管道中遇到了这个错误:

找不到与 yargs@^3.32.0 匹配的版本。在大多数情况下,您或您的依赖项之一正在请求一个不存在的包版本。

在我的构建管道中,我添加.npmrc了带有注册 url 的文件,该文件连接到提要。而且在提要中,这个yargs包不存在。我想知道如何在提要中添加额外的 npm 包?

标签: node.jsangularnpmazure-devops.npmrc

解决方案


在 Azure DevOps 源上添加其他 npm 包

要解决此问题,您可以将 npmjs.com 添加为供稿的上游源:

请检查文档Use packages from npmjs.com

  1. 编辑您的提要。选择页面右上角的齿轮图标以打开提要设置。
  2. 选择上游源枢轴。
  3. 在命令栏中选择添加上游源。
  4. 选择 Select a feed URL 并选择 npmjs.com ( https://registry.npmjs.org )。如果您愿意,可以自定义上游名称。
  5. 选择添加。

或者,您可以通过以下命令安装包 yargs:

npm install yargs

或者在 github 上克隆这个项目:

git clone http://github.com/bcoe/yargs.git

然后我们可以从命令行发布一个 npm 包


推荐阅读