Nexus 3作为npm存储库找不到一些依赖项:npm ERR!找不到404:

cod*_*ent 4 nexus node.js npm nexus3

我使用Nexus 3作为npm私人存储库.我有一个需要一些依赖项的项目,例如:@nodelib/fs.stat, @mrmlnc/readdir-enhanced@^2.2.1.

如果我执行以下npm install命令,一切正常:

sudo npm install -g @nodelib/fs.stat
+ @nodelib/fs.stat@1.1.0
added 1 package in 0.481s

sudo npm install -g @mrmlnc/readdir-enhanced@^2.2.1
+ @mrmlnc/readdir-enhanced@2.2.1
added 3 packages in 2.178s
Run Code Online (Sandbox Code Playgroud)

但我必须配置.npmrc以这种方式引用我的nexus npm存储库:

〜/ .npmrc:

registry=http://mynexus.com/repository/npmrepo
Run Code Online (Sandbox Code Playgroud)

现在,当我尝试安装我的私有项目npm install -g generator-myyeomangenerator失败,因为它无法下载这些依赖项.

事实上,现在我已经设置了我的.npmrc配置,如果我直接为这些依赖项执行npm install,我得到一个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
Run Code Online (Sandbox Code Playgroud)

日志文件不提供其他信息.

来自这些依赖项的公寓,通过npm repo运行其他一些安装工作ok事件:

sudo npm install -g jav
+ jav@1.0.2
added 71 packages in 9.628s
Run Code Online (Sandbox Code Playgroud)

它似乎与deps的@命名有关,这是失败执行的另一个例子:

npm install -g @angular/common@2.4.10
npm ERR! code E404
npm ERR! 404 Not Found: @angular/common@2.4.10

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
Run Code Online (Sandbox Code Playgroud)

我怎样才能解决这个问题?

cod*_*ent 7

修复了这个自定义的.npmrc文件,该文件使用公共npm存储库来处理那些无法通过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/
Run Code Online (Sandbox Code Playgroud)


rse*_*don 6

Apache 在 Nexus 前面运行吗?默认情况下,它不允许编码斜杠通过,这会破坏 npm 范围包的检索。

要修复它,请在您的 Apache 配置中添加以下内容:

# 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
Run Code Online (Sandbox Code Playgroud)

在此处查看更多详细信息:https : //issues.sonatype.org/browse/NEXUS-10570