'Can't start Angular application
Within the last few days, we have been encountering the following errors (and there doesn't seem to be match find in Google search):
npm start
ng serve
Compiling @angular/core : es2015 as esm2015
Error: Error on worker #1: TypeError: compiler_1.createMayBeForwardRefExpression is not a function
Any ideas why or workaround?
Solution 1:[1]
This error is caused by the version mismatch for most Angular framework packages(like core, common, compiler) with @angular/compiler-cli and @angular/language-service.
You should always use the same versions of these packages. Try using "^" with the version number.
Solution 2:[2]
Changing the package.json dependency as below resolved the issue for me
"@angular/compiler": "12.2.13", to "@angular/compiler": "^12.2.13",
Solution 3:[3]
Try to upgrade your global typscript package
npm install -g typescript@latest
Solution 4:[4]
As @a_tk explained, that is the usual issue here.
You need edit your package.json file and search for those packages (angular) and use the caret(^) instead of tilde(~) before the package version, example:
From this:
"@angular/cli": "~12.0.1",
To this:
"@angular/cli": "^12.2.0",
Then, to avoid related issues, I recommend delete node_modules directory and package-lock.json file and run:
npm i
I hope this help others.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | a_tk |
Solution 2 | manoj kumar bale |
Solution 3 | Renjith Krishnan |
Solution 4 | manuelpgs |