我使用nexus 3作为npm私有存储库。我有一个项目需要一些依赖项,如:@nodelib/fs.stat@mrmlnc/readdir-enhanced@^2.2.1
如果我执行以下npm install命令,一切正常:

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

但我必须配置.npmrc,才能以这种方式引用我的nexus npm存储库:
~/.npmrc:
registry=http://mynexus.com/repository/npmrepo

现在,当我尝试安装我的私有项目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

日志文件不提供其他信息。
从这些依赖关系中运行appart,通过npm repo运行其他一些installs work ok事件:
sudo npm install -g jav
+ [email protected]
added 71 packages in 9.628s

这似乎与DEP的命名有关,下面是执行失败的另一个例子:
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

我该怎么解决?

最佳答案

修复了此自定义.npmrc文件,该文件对无法通过Nexus解析的作用域包使用公共NPM存储库:

@angular:registry=https://registry.npmjs.org/
@nodelib:registry=https://registry.npmjs.org/
@mrmlnc:registry=https://registry.npmjs.org/
registry=http://mynexus.com/repository/npmrepo/

08-16 05:57