类型错误:angularCompiler.getNextProgram不是函数

我在我的机器上使用 angular 11.2,我想运行一个 angular 12 项目。从 git 克隆后,我运行了以下命令。

  1. npm install
  2. ng serve

但是我遇到了以下错误并且无法运行该项目。我读了这个问题,但它对我不起作用。

Error: ./src/main.ts
Module build failed (from ./node_modules/@ngtools/webpack/src/ivy/index.js):
TypeError: angularCompiler.getNextProgram is not a function
    at C:Usersthimira_pDesktopitrdepic-itrda-webnode_modules@ngtoolswebpacksrcivyplugin.js:376:100
    at processTicksAndRejections (internal/process/task_queues.js:93:5)

Error: ./src/polyfills.ts
Module build failed (from ./node_modules/@ngtools/webpack/src/ivy/index.js):
TypeError: angularCompiler.getNextProgram is not a function
    at C:Usersthimira_pDesktopitrdepic-itrda-webnode_modules@ngtoolswebpacksrcivyplugin.js:376:100
    at processTicksAndRejections (internal/process/task_queues.js:93:5)

Error: (webpack)-dev-server/client?http://0.0.0.0:0&sockPath=/sockjs-node
Module build failed (from ./node_modules/@ngtools/webpack/src/ivy/index.js):
TypeError: angularCompiler.getNextProgram is not a function
    at C:Usersthimira_pDesktopitrdepic-itrda-webnode_modules@ngtoolswebpacksrcivyplugin.js:376:100
    at processTicksAndRejections (internal/process/task_queues.js:93:5)

如何解决这个问题?

回答

升级@angular-devkit/build-angular@0.1100@angular-devkit/build-angular@12


回答

我在使用自定义 webpack.config的 Angular 应用程序中遇到了同样的问题-@angular-builders/custom-webpack作为依赖项。

Angular 和@angular-builders主要版本应该匹配。

通过更新@angular-builders/custom-webpack到最新版本解决:

npm install @angular-builders/custom-webpack@12.0.0


如果,在做安装后,你会得到这样的错误:
An unhandled exception occurred: Cannot find module 'webpack',尝试删除package-lock.jsonnode_modules,做一个干净的安装。


Github 问题:https : //github.com/just-jeb/angular-builders/issues/981


回答

尝试删除

“aot”:真的

来自 angular.json


以上是类型错误:angularCompiler.getNextProgram不是函数的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>