0

I have this package.json and I want to download the dependency xyz/typescript-sdk from a azure feed that don't have access to public registry like npmjs and the others dependencies downloads from the public registry

{
  "name": "@xyz/typescript-sdk",
  "description": "",
  "version": "0.0.1",
  "keywords": [
    "xyz",
    "typescript",
    "sdk"
  ],
  "main": "build/xyz-sdk.bundle.js",
  "types": "build/src/main.d.ts",
  "files": [
    "build/**/*"
  ],
  "repository": {
    "type": "git",
    "url": ""
  },
  "dependencies": {
    "@angular/animations": "~12.2.0",
    "@xyz/typescript-sdk": "file:xyz-typescript-sdk-0.0.1.tgz"
  },
  "devDependencies": {
    "@angular-builders/jest": "latest",
    "@angular-devkit/build-angular": "~12.2.5"
  },
  "husky": {
    "hooks": {
      "commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
    }
  }
}

The Azure instructions indicate to connect to npm feed I have to create a .npmrc file in the user's home and in the same directory as the package.json. I have tried creating the .npmrc file in my home and putting this syntax in the dependencies for @xyz/typescript-sdk:

"dependencies": {
"@xyz/typescript-sdk": "git+ssh://git@pkgs.dev.azure.com/ORGANIZATION/PROJECT/_packaging/FEED/npm/registry/
}

But I get this error:

npm WARN tar TAR_BAD_ARCHIVE: Unrecognized archive format
npm ERR! code TAR_BAD_ARCHIVE
npm ERR! TAR_BAD_ARCHIVE: Unrecognized archive 

Or in any case, is there a way to configure different registries through the .npmrc file?. In the azure instructions, they say to create a .npmrc file with the following

registry=https://pkgs.dev.azure.com/ORGANIZATION/PROJECT/_packaging/FEED/npm/registry/ 
                        
always-auth=true

Is there a way to add other registries in the npmrc file like the npmjs?

  • I’m not familiar with Azure but looking at the docs, I think you should create a `.npmrc` file and add the [token](https://learn.microsoft.com/en-us/azure/devops/artifacts/npm/npmrc?view=azure-devops&tabs=linux%2Cclassic) there. Then you can install the published package by running `npm i @xyz/typescript-sdk` and it will automatically install the latest version of the package and update your `package.json` file. – fardjad Apr 11 '23 at 23:23
  • How I am going to run it in a sh, I need to configure it to work in a single command. – cekodis681 cekodis681 Apr 12 '23 at 00:01
  • Not sure what you mean by running it in a single command. In this case, as long as you have a `.npmrc` file with the token, and have the dependency listed in `package.json`, running `npm i` should be enough to install the dependencies.If you want to run multiple commands, you can put them all in a shell script and run that – fardjad Apr 12 '23 at 00:07
  • check this https://stackoverflow.com/questions/49404870/how-to-set-auth-for-a-scoped-registry-in-npmrc – Lonli-Lokli Apr 12 '23 at 09:07

0 Answers0