简体   繁体   English

当package.json具有不正确的版本时,从npm迁移到yarn

[英]Migrating from npm to yarn when package.json has incorrect versions

I recently started working on a pre-existing react-native project, and upon setup I encountered a lot of dependency and versioning errors. 我最近开始研究一个预先存在的react-native项目,并且在设置时遇到了很多依赖项和版本控制错误。 The versions on package.json are incorrect for our project, and it caused errors when I ran it until we finally decided to just copy the node_modules folder into my repository from another team member's working repo instead of using npm install . package.json上的版本对于我们的项目是不正确的,当我运行它时它会导致错误,直到我们最终决定将node_modules文件夹从另一个团队成员的工作仓库复制到我的存储库而不是使用npm install

We'd like to migrate the project to Yarn so that this doesn't continue to happen, but when I try to create a yarn.lock file using either yarn install or yarn install --check-files , I end up with wrong versions and a broken project. 我们想将项目迁移到Yarn以便这不会继续发生,但是当我尝试使用yarn installyarn install --check-files创建yarn.lock yarn install --check-files ,我最终会得到错误的版本和一个破碎的项目。 Is there any way to generate a yarn.lock file, and potentially a new package.json, based on the versions that are in the node_modules directory? 有没有办法生成一个yarn.lock文件,可能是一个新的package.json,基于node_modules目录中的版本?

Have you try npm init ? 你试过npm init吗?

It will ask you a few questions and generate the package.json with dependencies based on existing /node_modules. 它会问你一些问题,并根据现有的/ node_modules生成带有依赖关系的package.json。

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

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