NPM安装在计算机之间的行为有所不同 [英] NPM Install behaving differently between computers

查看:103
本文介绍了NPM安装在计算机之间的行为有所不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不确定为什么会这样...谷歌搜索,但我似乎找不到答案.我有2个Mac,在每个Mac上都有一个包含相同package.json文件的文件夹,其中包含20个依赖项的列表.当我在...上运行"npm install"时

Not sure why this is happening... been Googling but I can't seem to find an answer. I have 2 macs, on each of them I have a folder containing the same package.json file, which contains a list of 20 dependencies. When I run "npm install" on...

计算机1:将所有列出的依赖项安装在自己的文件夹中-总共20个文件夹.

Computer 1: installs all the listed dependencies within their own folders - 20 folders total.

计算机2:安装了大量不同的文件夹-确切地说是561.这些额外的文件夹似乎是我在package.json中列出的主要依赖项的依赖项.

Computer 2: installs a ton of different folders - 561 to be exact. These extra folders appear to be dependencies of the main dependencies that I have listed in package.json.

很好奇为什么会发生这种情况,以及是否有办法控制npm如何下载和分组依赖项?我感谢下载561个文件夹的计算机的整体文件大小较小...但是在某些情况下,我需要组织分组的依存关系.

Just curious why this is happening, and if there is anyway to control how npm downloads and groups dependencies? I appreciate the smaller overall file size of the computer downloading 561 folders... but there may be instances where I require the organization of the grouped dependencies.

谢谢!

推荐答案

最新版本的NPM可以进行扁平化"安装,其依赖项嵌套的深度不如早期版本.听起来,如果您比较NPM版本,就会发现两台计算机上的版本不同.

The newest version of NPM does a "flatter" install with dependencies not nested as deep as the earlier version. It sounds like if you compare NPM versions, you will find you have different versions on the two computers.

这是有关旧方法的文章:

Here's an article about the older way:

npm正在以奇怪的递归方式安装依赖项

然后,更改有关新方法的日志信息:

And, change log info about the new way:

https://github.com/npm /npm/blob/master/CHANGELOG.md#flat-flat-flat

此方法的主要优点之一是共享(而不是重复)一个以上的父模块使用的模块依赖关系.在新的平面方案中,只有一个模块的副本在多个地方使用,而不是多个副本.

One of the main advantages of this is the sharing (rather than duplicating) of module dependencies used by more that one parent module. In the new flat scheme, there is only one copy of the module that is used in more than one place rather than many copies.

这篇关于NPM安装在计算机之间的行为有所不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆