Angular 12: ng serve --open 耗时太长且有很多消息

Angular 12: ng serve --open takes too long and have a lot of message

所以我的angular 12之前有一个问题你可以点击参考

所以我现在有点修复它,我可以做 ng serve --open,但我收到了这条消息,可能是一个错误,它永远不会提供或显示输出,只是它需要很多时间。

错误:

D:rdYR\AppDev\bigProject\public>ng serve public
⠙ Generating browser application bundles (phase: setup)...(node:12832) UnhandledPromiseRejectionWarning: Error: The Angular Compiler requires TypeScript >=4.4.2 and <4.5.0 but 4.3.5 was found instead.
    at checkVersion (file:///D:/3rdYR/AppDev/bigProject/public/node_modules/@angular/compiler-cli/bundles/index.js:17440:11)
    at verifySupportedTypeScriptVersion (file:///D:/3rdYR/AppDev/bigProject/public/node_modules/@angular/compiler-cli/bundles/index.js:17444:3)
    at new NgtscProgram (file:///D:/3rdYR/AppDev/bigProject/public/node_modules/@angular/compiler-cli/bundles/index.js:17594:7)
    at AngularWebpackPlugin.updateAotProgram (D:rdYR\AppDev\bigProject\public\node_modules\@angular-devkit\build-angular\node_modules\@ngtools\webpack\src\ivy\plugin.js:321:32)
    at D:rdYR\AppDev\bigProject\public\node_modules\@angular-devkit\build-angular\node_modules\@ngtools\webpack\src\ivy\plugin.js:198:24
    at Hook.eval [as call] (eval at create (D:rdYR\AppDev\bigProject\public\node_modules\tapable\lib\HookCodeFactory.js:19:10), <anonymous>:24:1)
    at Hook.CALL_DELEGATE [as _call] (D:rdYR\AppDev\bigProject\public\node_modules\tapable\lib\Hook.js:14:14)
    at Compiler.newCompilation (D:rdYR\AppDev\bigProject\public\node_modules\webpack\lib\Compiler.js:1054:30)
    at D:rdYR\AppDev\bigProject\public\node_modules\webpack\lib\Compiler.js:1099:29
    at eval (eval at create (D:rdYR\AppDev\bigProject\public\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:31:1)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:12832) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:12832) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
⠼ Generating browser application bundles (phase: setup)...

现在还在发电,但至少会持续10分钟。

您的项目中安装了错误的打字稿版本。 UnhandledPromiseRejectionWarning:错误:Angular 编译器要求 TypeScript >=4.4.2 和 <4.5.0,但找到了 4.3.5。

更改你的包 Json 你的 Typescript 版本为 4.4.2 和 npm install 比再次尝试 ng serve :)