简体   繁体   English

保持yarn.lock跨平台?

[英]Maintaining yarn.lock cross-platform?

I generally run the npm install command on my local dev machine (OSX) in order to collect all of my node modules in one place so I can look through them, get completion in my IDE, etc. 我通常在我的本地开发机器(OSX)上运行npm install命令,以便在一个地方收集我的所有节点模块,这样我就可以查看它们,在我的IDE中完成等等。

However, I'm new to using yarn, and it seems with the lockfile that some versions of packages are locked to be specific to my development environment, so when I yarn down my package.json in an alpine docker container it tells me things like 但是,我刚接触使用yarn,并且看起来锁文件中某些版本的软件包被锁定为特定于我的开发环境,所以当我在一个高山的docker容器中打包我的package.json时它会告诉我类似的东西

warning fsevents@1.1.2: The platform "linux" is incompatible with this module.

Which I'm guessing means that the package was locked to a specific version or set of dependencies which is specific to OSX. 我猜这意味着包被锁定到特定于OSX的特定版本或一组依赖项。

This doesn't seem to be breaking any functionality yet, but I'm concerned that it might down the line. 这似乎没有打破任何功能,但我担心它可能会下线。 Any ideas on how to maintain yarn for cross-platform development? 关于如何保持纱线跨平台开发的任何想法? Or is what I'm seeing here totally benign? 或者我在这里看到的完全是良性的?

Not really an answer but... 不是真的答案,但......

Your example is not an issue specific to yarn, yarn.lock or npm and package-lock.json for that matter. 您的示例不是特定于yarn, yarn.locknpmpackage-lock.json的问题。 The fsevents package is specifically for MacOS file system events. fsevents包专门用于MacOS文件系统事件。 As such, it won't work on any other platform (eg Linux). 因此,它不适用于任何其他平台(例如Linux)。

If you are using this package directly, you may want to consider a replacement that is cross-platform. 如果您直接使用此软件包,则可能需要考虑跨平台的替代软件。

If this warning is coming up because of a dependency to your project, you may want to make sure that it (and it's dependencies) are cross-platform as well. 如果由于对项目的依赖性而出现此警告,您可能希望确保它(以及它的依赖项)也是跨平台的。

Oftentimes platform-specific packages exist to make up for a feature that is either incompatible or not present on that platform. 通常,存在特定于平台的包以弥补在该平台上不兼容或不存在的特征。 So long as you (or your dependency) are handling this correctly, in a per-platform way, you should be fine. 只要你(或你的依赖)正确地处理这个问题,以平台的方式,你应该没问题。 These packages are listed in package.json as optional because they are expected to fail on platforms they are not designed for (hence the warning). 这些包在package.json列为可选项,因为它们预计会在不是为其设计的平台上失败(因此警告)。

For more information on this, Yarn has a good explanation of dependency types which includes optional dependencies: 有关这方面的更多信息,Yarn对依赖类型有一个很好的解释,其中包括可选的依赖项:

This is useful for dependencies that won't necessarily work on every machine and you have a fallback plan in case they are not installed... 这对于不一定适用于每台计算机的依赖项非常有用,并且如果未安装,则会有后备计划...

https://yarnpkg.com/lang/en/docs/dependency-types/ https://yarnpkg.com/lang/en/docs/dependency-types/

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

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