Reputation: 166
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?
Upvotes: 2
Views: 3606
Reputation: 959
Both answers from @a_tk and @manuelpgs could/should resolve the issue but most important is :
Using ng update
you might shorten process to see what needs to update to what version. There might be additional packages which don't provide 'ng update' capabilities that are outdated but it might help solving issue.
Upvotes: 0
Reputation: 1372
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.
Upvotes: 1
Reputation: 21
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.
Upvotes: 2
Reputation: 1250
Try to upgrade your global typscript package
npm install -g typescript@latest
Upvotes: 0
Reputation: 21
Changing the package.json dependency as below resolved the issue for me
"@angular/compiler": "12.2.13", to "@angular/compiler": "^12.2.13",
Upvotes: 0