简体   繁体   English

npm安装失败,因为注册表中缺少软件包

[英]npm install fails because package is missing in registry

I have an issue with a project where we are using node and brunch. 我在使用节点和早午餐的项目中遇到问题。 The issue is current specific to brunch, but could occur for any module would be my guess. 这个问题是当前特定于早午餐的,但是我想可能会发生在任何模块上。

The easiest way to currently reproduce this, is to do the following in a new folder: 当前最简单的方法是在新文件夹中执行以下操作:

npm init
npm install --save-dev brunch

The issue here is that brunch depends on loggy, which in turn depends on ansi-color, which no longer has an entry in the npmregistry: 这里的问题是早午餐取决于逻辑,而逻辑又取决于ansi-color,后者在npmregistry中不再具有条目:

https://registry.npmjs.org/ansi-color https://registry.npmjs.org/ansi-color

I think this might be the github project: https://github.com/loopj/commonjs-ansi-color 我认为这可能是github项目: https//github.com/loopj/commonjs-ansi-color

In any case, I am unable to proceed, and all our builds fail because they are not able to fetch the given dependency. 无论如何,我都无法继续,我们所有的构建都失败了,因为它们无法获取给定的依赖关系。

I could perhaps use npm shrinkwrap in some way, but that depends on the modules already existing in node_modules, which I am currently missing. 我也许可以以某种方式使用npmrinkwrap,但这取决于node_modules中已经存在的模块,而我目前缺少这些模块。

So how can I force npm to use ansi-color from a different location, or ignore the dependency? 那么如何强制npm从其他位置使用ansi-color或忽略依赖关系?

Not sure about npm 2 but you can fix this with beta npm 3. npm 3 has flat node_modules directory. 不确定npm 2,但可以使用beta npm 3进行修复。npm 3具有平坦的node_modules目录。 So sub modules can sit in the top level. 因此子模块可以位于顶层。 Read the Changelog . 阅读变更日志

The missing modules can be installed directly from their Github repo as a toplevel dependency in your project. 缺少的模块可以直接从其Github存储库中安装,作为项目中的顶级依赖项。 If npm finds the module with the same version in node_modules directory, it won't look for it anymore in the registry. 如果npm在node_modules目录中找到具有相同版本的模块,则它将不再在注册表中寻找它。

Install npm 3: 安装npm 3:

npm install -g npm@3-latest 

Then install depencies: 然后安装依赖关系:

//install missing module from other location
npm install  https://github.com/loopj/commonjs-ansi-color.git --save-dev
npm install --save-dev brunch

看起来ansi-color回到了npm注册表(“ https://registry.npmjs.org/ansi-color ”回到了在线)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM