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

时间:2023-01-18 07:48:42

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:

这里的问题是早午餐依赖于loggy,而log依赖于ansi-color,它在npmregistry中不再有条目:

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.

我可能会以某种方式使用npm shrinkwrap,但这取决于node_modules中已存在的模块,我目前缺少这些模块。

So how can I force npm to use ansi-color from a different location, or ignore the dependency?

那么如何强制npm从不同的位置使用ansi-color,或者忽略依赖?

2 个解决方案

#1


4  

Not sure about npm 2 but you can fix this with beta npm 3. npm 3 has flat node_modules directory. So sub modules can sit in the top level. Read the Changelog.

不确定npm 2但是你可以用beta npm 3解决这个问题.npm 3有flat node_modules目录。所以子模块可以位于顶层。阅读更改日志。

The missing modules can be installed directly from their Github repo as a toplevel dependency in your project. If npm finds the module with the same version in node_modules directory, it won't look for it anymore in the registry.

缺少的模块可以直接从他们的Github仓库安装,作为项目中的顶层依赖项。如果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

#2


-1  

It looks like ansi-color is back on the npm registry ("https://registry.npmjs.org/ansi-color" is back online)

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

#1


4  

Not sure about npm 2 but you can fix this with beta npm 3. npm 3 has flat node_modules directory. So sub modules can sit in the top level. Read the Changelog.

不确定npm 2但是你可以用beta npm 3解决这个问题.npm 3有flat node_modules目录。所以子模块可以位于顶层。阅读更改日志。

The missing modules can be installed directly from their Github repo as a toplevel dependency in your project. If npm finds the module with the same version in node_modules directory, it won't look for it anymore in the registry.

缺少的模块可以直接从他们的Github仓库安装,作为项目中的顶层依赖项。如果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

#2


-1  

It looks like ansi-color is back on the npm registry ("https://registry.npmjs.org/ansi-color" is back online)

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