ค้นหาเว็บไซต์

angular - TypeError: 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:\Users\thimira_p\Desktop\itrd\epic-itrda-web\node_modules\@ngtools\webpack\src\ivy\plugin.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:\Users\thimira_p\Desktop\itrd\epic-itrda-web\node_modules\@ngtools\webpack\src\ivy\plugin.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:\Users\thimira_p\Desktop\itrd\epic-itrda-web\node_modules\@ngtools\webpack\src\ivy\plugin.js:376:100
    at processTicksAndRejections (internal/process/task_queues.js:93:5)

จะแก้ปัญหานี้ได้อย่างไร?

คำตอบ #1

ฉันมีปัญหาเดียวกันในแอป Angular ที่ใช้ custom webpack.config - โดยมี @angular-builders/custom-webpack เป็น dependency

เวอร์ชันหลักของ 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.json และ node_modules แล้วติดตั้งใหม่แบบสะอาด


ปัญหา Github: https://github.com/just-jeb/angular-builders/issues/981

คำตอบ #2

อัปเกรดจาก @angular-devkit/[email  ไปยัง @angular-devkit/build-angular@12

บทความที่เกี่ยวข้อง