尝试将 Angular 更新到 13 破坏了一堆东西,现在尝试返回 Angular 11 怎么办?

发布于 2025-01-10 06:44:10 字数 1094 浏览 0 评论 0原文

首先,我是唯一一个参与这个项目的人,所以我们可以完全摧毁除了代码之外的所有东西。

我已经尝试过类似的操作,但没有效果,

npm uninstall -g @angular/cli
npm cache clean
npm install -g @angular/cli@11

当我尝试运行 ngserve 时,

bullshit@ChristohersMBP2 decksite % ng serve
This version of CLI is only compatible with Angular versions ^13.0.0,
but Angular version 12.2.16 was found instead.

Please visit the link below to find instructions on how to update Angular.
https://update.angular.io/

当前情况是这样的,我所做的稍微有用的就是恢复到项目中的旧提交,但现在这不再是一个选择。

所以我的想法是清除我的 package.json 并删除 package-lock.json 并删除 node_modules

并尝试再次安装 Angular 11 cli (以及我需要的所有其他 npm 库,因为我不再填充 package.json。

或者更好的是从较旧的提交中获取 package.json 因为这仍然是一个选项,然后执行无论我必须在本地做什么才能完全擦除所有内容删除当前的 package.jsonpackage-lock.jsonnode_modules 并运行 npm uninstall 上的所有内容?我不知道我必须做什么才能擦除。

将新的 package.json 放入我的 Angular 项目中,然后点击

看起来像的 npm install 命令。非常好的解决方案,我打对地方了吗?

First I am the only one working on this project so we can completely nuke everything but the code of course.

I have tried things like this with no effect

npm uninstall -g @angular/cli
npm cache clean
npm install -g @angular/cli@11

when I try to run ng serve the current situation is like this

bullshit@ChristohersMBP2 decksite % ng serve
This version of CLI is only compatible with Angular versions ^13.0.0,
but Angular version 12.2.16 was found instead.

Please visit the link below to find instructions on how to update Angular.
https://update.angular.io/

What I did do that worked for a little is revert back to a old commit in my project but now that is not an option any more.

so my thoughts are to clear my package.json and delete package-lock.json and delete node_modules

and try to install the angular 11 cli again (as well as all other npm libraries i need since I no longer have my package.json populated.

Or even better go grab the package.json from a older commit since that is still an option and then do whatever I have to do on my local to completely wipe everything that is not source code. Delete current package.json , package-lock.json, node_modules, and run npm uninstall on everything? IDK whatever I have to do to wipe.

Place the new package.json in my angular project and then hit the npm install command.

that seems like a really good solution, am I hitting in the right place?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

长发绾君心 2025-01-17 06:44:10

我通常通过 (ng update) 执行以下操作:

  1. 确保您完全投入并正常工作。创建一个分支“angular_13_update”
  2. 运行 ng update,它将返回一份要更新的内容的报告。
  3. 我通常根据列表进行 npm install @angular/x, y, z
  4. 看看进展如何。使用第 3 方的东西有时会导致一些投诉。 --force 有时可以完成该部分。
  5. 如果该位成功,则测试构建并查看结果是什么。

我相信从 11 点到 13 点,您将会看到 Webpack 5 更新和其他重大更改。因此,根据您拥有的第 3 方 ie commonjs 样式包的数量,您可能需要使用架构师->构建->选项来调整您的 angular.json 文件:

"allowedCommonJsDependencies": [
                            "uuid",
                            "ulid",
                            "url",
                            "lodash/get",
                            "lodash/isEmpty",
                            "lodash/isEqual",
                            "@aws-amplify/core",
..etc 

I typically do the following via (ng update):

  1. Make sure you are fully committed and functioning. Make a branch 'angular_13_update'
  2. Run ng update, it will come back with a report of things to update.
  3. I commonly npm install @angular/x, y, z per the list.
  4. See how it goes. Using 3rd party stuff sometimes leads to some complaints. --force can some times get that part done.
  5. If that bit succeeds test a build and see what broke as a result.

I believe from 11 to 13 you are going by Webpack 5 updates and other breaking changes. So depending on how much 3rd party i.e. commonjs style packages you have you may need to tweak your angular.json file with architect->build->options:

"allowedCommonJsDependencies": [
                            "uuid",
                            "ulid",
                            "url",
                            "lodash/get",
                            "lodash/isEmpty",
                            "lodash/isEqual",
                            "@aws-amplify/core",
..etc 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文