yarn not working with nexus 3 npm proxy repository
Asked Answered
K

3

7

I have set up a Nexus 3 Manager to host private npm packages. The nexus contains three npm repositories, one hosted, one proxy and one group to combine the other two. The npm bearer realm if activated and i am using a nexus user with admin role for testing.

I have now set up a simple angular library via the angular cli for publishing. In the angular project i configured the .npmrc like follows:

registry=https://urlToMyNexus/repo/npm-all/
_authToken=NpmToken.XXXX

Now i want to install all packages over the set up group repository in nexus via yarn install. The .npmrc and .yarnrc in home home dictionary are empty.

The preconfigured package.json looks looks like follows:

{
  "name": "test-libraries",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "~9.1.1",
    "@angular/common": "~9.1.1",
    "@angular/compiler": "~9.1.1",
    "@angular/core": "~9.1.1",
    "@angular/forms": "~9.1.1",
    "@angular/platform-browser": "~9.1.1",
    "@angular/platform-browser-dynamic": "~9.1.1",
    "@angular/router": "~9.1.1",
    "rxjs": "~6.5.4",
    "tslib": "^1.10.0",
    "zone.js": "~0.10.2"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.901.1",
    "@angular-devkit/build-ng-packagr": "~0.901.1",
    "@angular/cli": "~9.1.1",
    "@angular/compiler-cli": "~9.1.1",
    "@angular/language-service": "~9.1.1",
    "@types/jasmine": "~3.5.0",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "^12.11.1",
    "codelyzer": "^5.1.2",
    "jasmine-core": "~3.5.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~4.4.1",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage-istanbul-reporter": "~2.1.0",
    "karma-jasmine": "~3.0.1",
    "karma-jasmine-html-reporter": "^1.4.2",
    "ng-packagr": "^9.0.0",
    "protractor": "~5.4.3"
    "ts-node": "~8.3.0",
    "tslint": "~6.1.0",
    "typescript": "~3.8.3"
  }
}

The yarn install command is now able to install all @angular packages in the dependencies, but fails at rxjs. It gives the error error Couldn't find package "rxjs" on the "npm" registry.

If I try npm install with the same configuration all packages are installed correctly over the nexus repository.

Does anybody had the same problem?

Kenward answered 24/4, 2020 at 11:56 Comment(0)
G
7

I faced the same problem this week. When I use yarn it fails with error Couldn't find package "@egjs/hammerjs" on the "npm" registry. After unistalling node_modules and yarn.lock it can show another package name, but error is the same. However, if I use npm install instead yarn - installation works fine. In my case, it's not an option, because project is more than a year in development and I don't want to replace package manager because of it. I will investigate this further and edit this post if I would find a solution that works with yarn

Update: For me following steps did resolve this issue:

  1. remove .yarnrc and .npmrc file
  2. run command yarn config delete registry to delete current registry url from yarn inner config
  3. Create .npmrc with following content
registry=https://nexus-registry-url.com
always-auth=true
_auth=<base64-token-value>

After this steps yarn install works for my local machine and for our project CI/CD in docker.

Guidotti answered 10/7, 2020 at 6:21 Comment(2)
It doesn't work for me, I can not delete the default yarn registryMortality
always-auth=true did the trick. I had to add it manually since it is not a valid setting from NPM version 7+, so npm config set always-auth true doesn't work. Luckily, modern NPM just ignores it.Olshausen
S
3

You'll need to add this in .npmrc to be always authenticated:

always-auth=true
Stature answered 16/5, 2022 at 1:44 Comment(0)
E
1

The issue is with the yarn.lock file. The lockfile generated by yarn includes the registry for all the dependencies installed. If you want to change the registry, you will need to delete the yarn.lock file and run yarn install again. That should use the new registry set in the .npmrc file.

Eva answered 1/6, 2022 at 9:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.