Sau*_*ari 3 node.js npm angular-universal angular
我需要将 SSR 用于我现有的 Angular 项目之一。为此,我已将我的一个项目从 v8 迁移到 v13.0.0,这本身就花费了很多时间。
\n然而,现在该应用程序在 v13.0.0 上运行良好,我尝试使用以下命令向其添加 SSR
\n\n\nng 添加@nguniversal/express-engine
\n
此命令似乎添加了通用版本 13.0.1,但它一直失败,并出现类似于以下内容的错误:
\n\n\nD:\\my-app-universal>ng add @nguniversal/express-engine i Using package\nmanager: npm \xe2\x88\x9a Found compatible package version:\n@nguniversal/express-engine@13.0.1. \xe2\x88\x9a Package information loaded.
\nThe package @nguniversal/express-engine@13.0.1 will be installed and\nexecuted. Would you like to proceed? Yes npm ERR! code ERESOLVE npm\nERR! ERESOLVE unable to resolve dependency tree npm ERR! npm ERR!\nWhile resolving: my-app-universal@0.0.0 npm ERR! Found:\n@angular/animations@13.0.3 npm ERR! node_modules/@angular/animations\nnpm ERR! @angular/animations@"~13.0.0" from the root project npm\nERR! npm ERR! Could not resolve dependency: npm ERR! peer\n@angular/animations@"13.2.3" from @angular/platform-server@13.2.3 npm\nERR! node_modules/@angular/platform-server npm ERR! peer\n@angular/platform-server@"^13.0.1" from\n@nguniversal/express-engine@13.0.1 npm ERR!
\n
\nnode_modules/@nguniversal/express-engine npm ERR!
\n@nguniversal/express-engine@"13.0.1" from the root project npm ERR!\nnpm ERR! Fix the upstream dependency conflict, or retry npm ERR! this\ncommand with --force, or --legacy-peer-deps npm ERR! to accept an\nincorrect (and potentially broken) dependency resolution. npm ERR! npm\nERR! See\nC:\\Users\\saurabhtiwari\\AppData\\Local\\npm-cache\\eresolve-report.txt for\na full report.npm ERR! A complete log of this run can be found in: npm ERR!
\n
\nC:\\Users\\saurabhtiwari\\AppData\\Local\\npm-cache_logs\\2022-02-20T12_03_46_821Z-debug.log\n\xc3\x97 Package install failed, see above.
I have tried a lot to read through the errors and updating package.json to match the required version of peers but it just doesn't go away.
\nIs there a systematic way to resolve these errors.\nIs there a particular version of universal that might go well with Angular 13.
\nAny suggestions are welcomed.
\n我遵循@misha130 的评论建议并修复了版本号。我不需要使用--legacy-peer-deps或进行安装--force。
解决方案是升级@angular/cli& @angular/core。
全新安装后,我的初始版本是13.0.4. 您将需要一次升级它们,因为如果存储库中存在暂存且未提交的更改,则更新命令会失败。
ng update @angular/cli
git add . && git commit -m 'nguniversal fix 1 - update @angular/cli'
ng update @angular/core
git add . && git commit -m 'nguniversal fix 2 - update @angular/core'
ng add @nguniversal/express-engine
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1542 次 |
| 最近记录: |