Nexus 3 as npm repository can't find some dependencies: npm ERR! 404 Not Found:
Asked Answered
A

2

8

I am using Nexus 3 as npm private repository. I have a project that requires some dependencies such as: @nodelib/fs.stat, @mrmlnc/readdir-enhanced@^2.2.1.

If I execute the following npm install commands everything works alright:

sudo npm install -g @nodelib/fs.stat
+ @nodelib/[email protected]
added 1 package in 0.481s

sudo npm install -g @mrmlnc/readdir-enhanced@^2.2.1
+ @mrmlnc/[email protected]
added 3 packages in 2.178s

But I have to configure .npmrc to reference my nexus npm repository this way:

~/.npmrc:

registry=http://mynexus.com/repository/npmrepo

Now when I try to install my private project npm install -g generator-myyeomangenerator if fails because it can't download those dependencies.

In fact, now that I have set up my .npmrc config if I directly execute npm install for those dependencies I get a 404:

sudo npm install -g @nodelib/fs.stat
npm ERR! code E404
npm ERR! 404 Not Found: @nodelib/fs.stat@latest

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/myuser/.npm/_logs/2018-06-04T21_55_56_792Z-debug.log

The log file doesn't provide additional info.

Appart from those dependencies, running some other installs work ok event through the npm repo:

sudo npm install -g jav
+ [email protected]
added 71 packages in 9.628s

It seems to be related to the @ naming of the deps, here's another example of failing execution:

npm install -g @angular/[email protected]
npm ERR! code E404
npm ERR! 404 Not Found: @angular/[email protected]

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/myuser/.npm/_logs/2018-06-04T22_01_02_384Z-debug.log

How can I fix this?

Acculturate answered 4/6, 2018 at 22:2 Comment(0)
A
11

Fixed with this custom .npmrc file that uses the public npm repository for those scoped packages that can't be resolved through Nexus:

@angular:registry=https://registry.npmjs.org/
@nodelib:registry=https://registry.npmjs.org/
@mrmlnc:registry=https://registry.npmjs.org/
registry=http://mynexus.com/repository/npmrepo/
Acculturate answered 4/6, 2018 at 22:46 Comment(3)
Does this mean that scoped packages cannot be used with a Nexus private registry?Herder
@danwellman, did you found an answer to your question??Circumsolar
Sorry, I don't recall - this was in a previous job, hence in a previous lifetime!Herder
B
11

Is Apache running in front of Nexus? By default it won't allow encoded slashes to pass through, this breaks retrieval of npm scoped packages.

To fix it, add the following in your Apache config :

# Solution for Apache httpd < 2.0.52
AllowEncodedSlashes On

# Solution for Apache httpd 2.0.52 to 2.2.8 
AllowEncodedSlashes NoDecode
# The ProxyPass directive may need the nocanon option, as shown below :
ProxyPass / http://localhost:8081/ nocanon

See more details here: https://issues.sonatype.org/browse/NEXUS-10570

Besse answered 5/6, 2018 at 13:59 Comment(1)
Thanks for the info, I think there is an Apache server in front of it, I’ll check it out.Acculturate

© 2022 - 2024 — McMap. All rights reserved.