为什么我在不同的系统上运行 `npm install` 会得到截然不同的 `package-lock.json` 文件 [英] Why do I get vastly different `package-lock.json` files when I run `npm install` on different systems

查看:87
本文介绍了为什么我在不同的系统上运行 `npm install` 会得到截然不同的 `package-lock.json` 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用相同的 git 存储库,如果我删除 node_modulespackage-lock.json,我的期望是运行 npm install 应该生成每次都使用相同的 package-lock.json 文件(提供或获取一些可能在此期间由发布者更新的模块.

With the same git repository, if I delete node_modules and package-lock.json, my expectation is that running npm install should generate the same package-lock.json file each time (give or take a few modules that might get updated by the publisher in the interim.

我发现我得到非常不同的文件,这取决于我是在 OSX 机器还是 Linux 机器上执行此操作.

What I'm finding is that I get vastly different files depending on whether I do this on an OSX machine versus a Linux machine.

这是意料之中的事吗?如果是这样,提交 package-lock.json 文件的价值是什么,因为它在这些系统之一上无效.如果没有,这里会发生什么?

Is this to be expected? If so, what value does committing the package-lock.json file hold, since it will be invalid on one of these systems. If not, what might be going on here?

推荐答案

某些依赖项在某些平台上是可卸载的.你可能有一些可以安装在 OSX 机器上,但不能安装在 Linux 上.这就是为什么每次执行 npm i 时,package-lock.json 都会更新

Some dependencies are uninstallable on some platforms. You may have some of them that can be installed on OSX machine but not on Linux. That's why every time you execute npm i, the package-lock.json is updated

例如,正如其他一些用户指出的那样,有一个包fsevents 对操作系统有严格要求

For example, as some other users pointed out there is a package fsevents package which has strict requirement of os

你可以在 github 上找到一些未解决的问题:

You can find some open issues on github:

https://github.com/npm/npm/issues/17722

https://github.com/npm/npm/issues/18202

这篇关于为什么我在不同的系统上运行 `npm install` 会得到截然不同的 `package-lock.json` 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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