Angular 9 - NGCC fails with an unhandled exception

后端 未结 16 1511
离开以前
离开以前 2020-12-24 05:40

Buidling the application after having upgraded dependcies to Angular 9 (and having performed necessary code changes) throws an error:

Compiling @ang

相关标签:
16条回答
  • 2020-12-24 06:42

    This issue is becuase you might be running your app on any port and angular ngcc was assigned with a particular process id which was specified and locked in a file called __ngcc_lock_file__ inside \node_modules\@angular\compiler-cli\ngcc. If you are doing a hard system turn off or if your os crashed, this lock file will be there in the node_modules. And once you turn on you machine and trying to start the application again, angular cli will check this lock file and trying to find the process id specified in the file. Most of the time that process id will be missing since you did a complete machine restart and it will throw the this error.

    Solution 1. remove node_modules and do npm install

    Solution 2. Smart solution - delete the lock file as below.

    Go to `\node_modules\@angular\compiler-cli\ngcc`
    

    find the file named __ngcc_lock_file__ delete it. Done.

    Happy hacking

    0 讨论(0)
  • 2020-12-24 06:42

    Adding "postinstall": "ngcc" to "scripts" in package.json helped me to fix this

    0 讨论(0)
  • 2020-12-24 06:42

    Setting "enableIvy": false in tsconfig.json does fix that particular error. Isn't Ivy supposed to be usable already?

    This answer I found at enter link description here @clement911 answer and it worked for me after a lot of testing

    0 讨论(0)
  • 2020-12-24 06:44

    Check your node.js version with node -v. And check if Angular 9 is compatible with it. Updating node.js to the latest LTS version (12.8.1) worked for me. I did this with nvm (node version manager). Found a good instruction here.

    0 讨论(0)
提交回复
热议问题