Typescript Error:Initialization error (angular 2 language service). Cannot read property 'CommandTypes' of undefined

 Since updating to the latest Webstorm version (2018.2.1), I am seeing this error message in my Typescript window.

For the project, I am using Typescript 3.0.1 and Angular Language Service 6.0.5. I don't know where the angular 2 error message is coming from. 

Please advice on how to fix this.

5
25 comments

what Node.js version do you use? Please provide a screenshot of Settings | Languages & Frameworks | TypeScript page

0
Avatar
Janahan Balasingham

Hi Elena,

I am using Node.js 9.10.1 and Typescript 3.0.1. I have attached the screenshot as you requested.

In my package dependencies for the project, I have the following.

"@angular/language-service": "^6.0.5",
"typescript": "~3.0.1"

Hope that helps. Please advice on how to get rid of this error. It doesn't prevent me from compiling and running the project. But it's a nuisance to have an error message when there's supposed to be none.

 

0

Please try disabling Angular language service, or use Node.js 8.x: Angular service doesn't work with Node.js 9. See https://github.com/angular/angular/issues/21420

0

Hello,

I am receiving the same error message.


@angular/language-service -> 6.1.2

Node -> 8.11.1

Typescript -> 3.0.1

Webstorm -> 2018.2.2 EAP, also tried 2018.2.1

0

can't recreate in 2018.2.2 as well as in 2.1, with same Node.js and typescript versions. I'm using 

"@angular/language-service": "^6.1.0"

that is used by cli@latest

Can you recreate the issue with a new app created with ng new?

0

I'm working in an older project that doesn't use angular/cli

 

If I downgrade typescript to 2.9.2 then the error doesn't occur.

0

can you share a project that shows up the issue?

0

I just reproduced the issue by using the Angular Tour of Heroes demo project.

This demo project uses 

"@angular/language-service": "6.0.0"

 

Close all instances of Webstorm.  After cloning, I upgraded typescript to 3.0.1.  Then I opened it in Webstorm 2018.

 

git clone https://github.com/johnpapa/angular-tour-of-heroes

cd angular-tour-of-heroes

yarn add -D typescript

Open the project in WebStorm 2018.2.1.  Open up main.ts (or any typescript file)

 

0

thanks, recreated. Logged as https://youtrack.jetbrains.com/issue/WEB-34463, please follow it for updates

0

Now Angular v7 supported nodejs v10

https://github.com/angular/angular/blob/master/package.json#L11

 

And I have same error:

Error:Initialization error (angular 2 language service). Cannot read property 'CommandTypes' of undefined

 

Env:

  • Node v10.12.0
  • @angular/language-service v7.0.0
  • TypeScript v3.1.3
  • OS: Linux
6
Avatar
Aleksandar Pavlovic

Same problem as exposed above except when I select typescript 'Bundled' ( v3.0.1 )  with WebStorm.

When 'Bundled' selected no warning present.

Environment:

  • Node v10.12.0 or Node v8.12 
  • @angular/language-service v7.0.0
  • TypeScript v3.1.3
  • OS: Linux

Package.json

{
"name": "app",
"version": "1.0.0",
"license": "MIT",
"scripts": {
"ng": "ng"
},
"private": true,
"dependencies": {
"@angular/animations": "^7.0.0",
"@angular/cdk": "^7.0.0",
"@angular/common": "^7.0.0",
"@angular/compiler": "^7.0.0",
"@angular/core": "^7.0.0",
"@angular/forms": "^7.0.0",
"@angular/http": "^7.0.0",
"@angular/material": "^7.0.0",
"@angular/platform-browser": "^7.0.0",
"@angular/platform-browser-dynamic": "^7.0.0",
"@angular/router": "^7.0.0",
"@mdi/font": "^3.0.39",
"@ngrx/effects": "^6.1.0",
"@ngrx/router-store": "^6.1.0",
"@ngrx/store": "^6.1.0",
"@ngrx/store-devtools": "^6.1.0",
"ng2-pdf-viewer": "^5.2.0",
"ngx-logger": "^3.3.3",
"pdfjs-dist": "2.0.489",
"core-js": "^2.5.7",
"font-awesome": "^4.7.0",
"hammerjs": "^2.0.8",
"lodash": "^4.17.11",
"moment": "^2.22.2",
"rxjs": "^6.3.3",
"rxjs-compat": "^6.3.3",
"zone.js": "^0.8.26"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.10.2",
"@angular-devkit/build-ng-packagr": "~0.10.2",
"@angular/cli": "~7.0.2",
"@angular/compiler-cli": "^7.0.0",
"@angular/language-service": "^7.0.0",
"@compodoc/compodoc": "^1.1.5",
"@types/jasmine": "~2.8.9",
"@types/jasminewd2": "~2.0.5",
"@types/node": "~10.12.0",
"@types/pdfjs-dist": "^0.1.2",
"ng-packagr": "^4.4.0",
"tsickle": ">=0.33.0",
"codelyzer": "~4.5.0",
"concurrently": "4.0.1",
"cors": "^2.8.4",
"cross-env": "^5.2.0",
"express": "^4.16.4",
"glob": "^7.1.3",
"jasmine-core": "~3.2.1",
"jasmine-marbles": "^0.4.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~3.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.4",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^1.3.1",
"morgan": "^1.9.1",
"protractor": "~5.4.1",
"rimraf": "^2.6.2",
"ts-node": "~7.0.1",
"tslib": "^1.9.3",
"tslint": "~5.11.0",
"typescript": "~3.1.3",
"webpack": "^4.22.0"
}
}

4

Hi

I downloaded and installed Webstorm 2018.2.5 today.

I got an error in Webstorm on the angular app "my-app" from the Angular website (quickstart page):

"Error:Initialization error (angular 2 language service). Cannot read property 'CommandTypes' of undefined"

Before the Webstorm installation I had no Node.js yet on my machine.

I did install Node.js v11. After installing Node I installed Angular 7 (via "npm install -g @angular/cli").

I am running Windows10. I did not change any default Webstorm settings yet.

 

Has this something to do with version 11 of Node.js? 

 

 

 

 

0

I am having this problem as well with Angular 7 and 2018.2.5. When will the fix be pushed to a released version? It is a dealbreaker for Angular projects.

0

The fix will be included in next release (can be expected in a month); no patches for 2018.2 are planned

0

Same problem here, plz provide a fix!

0

please see above - fix is already provided in 2018.3 EAP

1

In 2018.3 EAP it works. Thank you!

1
Avatar
Andrew D Southwick

To install the 2018.3 EAP (as of 2018.11.07 today) in JetBrains Toolbox app select the Tools panel, scroll down the WebStorm, click "Install other version", and select the latest 2018.3 version.  This will trigger the download and installation process.  Once installation is complete, you will now have 2 versions of WebStorm, namely the OG production version, and the new EAP version.  Obviously you'll want to launch the EAP version and it will prompt you to import settings from the 2018.2.x version.  The whole process worked pretty seamlessly on my side. 

As of today the EAP version is marked as Beta, and per the post above by Elena it sounds like release of 2018.3 version is soon (yay)!  Regarding versions see below.  Installation of the latest EAP WebStorm does resolve the error I was seeing, and so far all seems stable with the Beta.  So given the results I'd recommend to anyone who needs to resolve this issue sooner rather than later just install the EAP, and you should be good to go. 👍😊🖖

$ ng --version

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 7.0.4
Node: 10.13.0
OS: win32 x64
Angular: 7.0.2
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.10.4
@angular-devkit/build-angular     0.10.4
@angular-devkit/build-optimizer   0.10.4
@angular-devkit/build-webpack     0.10.4
@angular-devkit/core              7.0.4
@angular-devkit/schematics        7.0.4
@angular/cli                      7.0.4
@ngtools/webpack                  7.0.4
@schematics/angular               7.0.4
@schematics/update                0.10.4
rxjs                              6.3.3
typescript                        3.1.6
webpack                           4.19.1

1

I unchecked angular/language-service and this error has gone :))

-1

Hi there,

 

No problem with

0

FWIW, I found that when adding "node" to the list of types in tsconfig.json, this error also crops up. In my case, I could remove that and the problem resolved itself in 2017.3.5.

0

Someone said this is breaking older angular projects?  I am on PhpStorm 2018.2 with the same error on the @latest CLI and @latest Angular(7)   I am still able to run angular fine and even completed a whole project and built with --prod and --aot   I really don't want to goto EAP if its just a warning, what stops working ? thanks! 

0

>Someone said this is breaking older angular projects?

No - it mostly affects _new_ projects using the latest cli

> I really don't want to goto EAP

https://youtrack.jetbrains.com/issue/WEB-34463 is fixed in 2018.3 that was released as long ago as November, so you don't need to goto EAP

And it's not a warning - the service doesn't start becaiuseof this error

0

Please sign in to leave a comment.