简体   繁体   English

如何在不破坏安装依赖树的情况下更新项目中的依赖包?

[英]How do I update dependency packages in a project without breaking the dependency tree on install?

I recently created a basic Typescript/React npm package for internal use at the company I'm working for, and since it was my first time building one, I used a tool called create-react-library (found here ) to help streamline the process.我最近创建了一个基本的 Typescript/React npm package 供我工作的公司内部使用,因为这是我第一次构建它,所以我使用了一个名为create-react-library的工具(在此处找到)来帮助简化过程。 The library made it quite easy to develop and publish my package, but the problem is that it hasn't been updated recently and thus several of the dependencies are out of date, including the version of React which the rest of our codebase is running on.该库使开发和发布我的 package 变得非常容易,但问题是它最近没有更新,因此一些依赖项已经过时,包括我们代码库 rest 运行的 React 版本. I can successfully install the package in the main project if I use the --legacy-peer-deps flag on npm install , but that doesn't seem like an ideal solution.如果我在npm install上使用--legacy-peer-deps标志,我可以在主项目中成功安装 package ,但这似乎不是一个理想的解决方案。 What's the best way to update the dependencies of my package without breaking the dependency tree?在不破坏依赖关系树的情况下更新我的 package 的依赖关系的最佳方法是什么? I tried going through my package.json , manually updating the version numbers to the latest, then deleted node_modules and re-ran npm install , but I got several dependency tree conflicts and the install failed.我尝试浏览我的package.json ,手动将版本号更新到最新版本,然后删除node_modules并重新运行npm install ,但我遇到了几个依赖树冲突并且安装失败。 What's the best approach here?这里最好的方法是什么?

Just set exact versions or ~, but no ^只需设置确切的版本或 ~,但没有 ^

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

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