Faizul Hussain
Faizul Hussain

Reputation: 166

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?

Upvotes: 2

Views: 3606

Answers (5)

StefaDesign
StefaDesign

Reputation: 959

Both answers from @a_tk and @manuelpgs could/should resolve the issue but most important is :

  • If you delete node_modules folder make sure you delete package-lock.json as well because if you dont you might spend hours on debugging versions (like silly me) and will not help you as long as locked file is present your versions might mismatch.

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

manuelpgs
manuelpgs

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

a_tk
a_tk

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

Zrelli Majdi
Zrelli Majdi

Reputation: 1250

Try to upgrade your global typscript package

npm install -g typescript@latest

Upvotes: 0

manoj kumar bale
manoj kumar bale

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

Related Questions