Vscode-ng-language-service: bundled @angular/language-service not loaded

Created on 14 Feb 2020  Â·  32Comments  Â·  Source: angular/vscode-ng-language-service

Describe the bug

--> is in the title

To Reproduce

Steps to reproduce the behavior:

  1. install & activate (=> latest -> 0.90012 (but also on 0.90003, and other)
  2. error (title)

Logs

Please attach two logs:

  1. Console output (Go to toolbar --> View --> Output, and copy the contents)
  2. Log file (Path is printed to the console output at startup)
[Info  - 8:53:43 AM] Angular language server process ID: 66846
[Info  - 8:53:43 AM] Using typescript v3.7.4 from /Users/x/.vscode/extensions/angular.ng-template-0.900.12/node_modules/typescript/lib/tsserverlibrary.js
[Info  - 8:53:43 AM] Using @angular/language-service v9.0.1 from /Users/x/.vscode/extensions/angular.ng-template-0.900.12/server/node_modules/@angular/language-service/bundles/language-service.umd.js
[Info  - 8:53:43 AM] Log file: /Users/x/Library/Application Support/Code/logs/20200211T164224/exthost1/Angular.ng-template/nglangsvc.log
[Error - 8:54:07 AM] No config file for /Users/x/src/app/test/test.component.html
/Users/x/.vscode/extensions/angular.ng-template-0.900.12/node_modules/typescript/lib/tsserverlibrary.js:131051
                throw error;
                ^

Error: Could not find source file: '/Users/x/src/app/test/test.component.html'.
    at getValidSourceFile (/Users/x/.vscode/extensions/angular.ng-template-0.900.12/node_modules/typescript/lib/tsserverlibrary.js:131047:29)
    at Object.getSemanticDiagnostics (/Users/x/.vscode/extensions/angular.ng-template-0.900.12/node_modules/typescript/lib/tsserverlibrary.js:131269:36)
    at Object.proxy.getSemanticDiagnostics (/Users/x/node_modules/@angular/language-service/bundles/language-service.umd.js:49429:32)
    at Session.sendPendingDiagnostics (/Users/x/.vscode/extensions/angular.ng-template-0.900.12/server/index.js:1020:39)
    at Timeout._onTimeout (/Users/x/.vscode/extensions/angular.ng-template-0.900.12/server/index.js:1001:19)
    at listOnTimeout (internal/timers.js:531:17)
    at processTimers (internal/timers.js:475:7) {
  ProgramFiles: [
    '/Users/x/.vscode/extensions/angular.ng-template-0.900.12/node_modules/typescript/lib/lib.es5.d.ts',
    '/Users/x/.vscode/extensions/angular.ng-template-0.900.12/node_modules/typescript/lib/lib.es2015.d.ts',
    '/Users/x/.vscode/extensions/angular.ng-template-0.900.12/node_modules/typescript/lib/lib.es2016.d.ts',
    '/Users/x/.vscode/extensions/angular.ng-template-0.900.12/node_modules/typescript/lib/lib.es2017.d.ts',
    '/Users/x/.vscode/extensions/angular.ng-template-0.900.12/node_modules/typescript/lib/lib.es2018.d.ts',
    '/Users/x/.vscode/extensions/angular.ng-template-0.900.12/node_modules/typescript/lib/lib.dom.d.ts',
    '/Users/x/.vscode/extensions/angular.ng-template-0.900.12/node_modules/typescript/lib/lib.es2015.core.d.ts',
    '/Users/x/.vscode/extensions/angular.ng-template-0.900.12/node_modules/typescript/lib/lib.es2015.collection.d.ts',
    '/Users/x/.vscode/extensions/angular.ng-template-0.900.12/node_modules/typescript/lib/lib.es2015.generator.d.ts',
    '/Users/x/.vscode/extensions/angular.ng-template-0.900.12/node_modules/typescript/lib/lib.es2015.iterable.d.ts',
    '/Users/x/.vscode/extensions/angular.ng-template-0.900.12/node_modules/typescript/lib/lib.es2015.promise.d.ts',
    '/Users/x/.vscode/extensions/angular.ng-template-0.900.12/node_modules/typescript/lib/lib.es2015.proxy.d.ts',
    '/Users/x/.vscode/extensions/angular.ng-template-0.900.12/node_modules/typescript/lib/lib.es2015.reflect.d.ts',
    '/Users/x/.vscode/extensions/angular.ng-template-0.900.12/node_modules/typescript/lib/lib.es2015.symbol.d.ts',
.
.
.
    '/Users/…/node_modules/tslib/tslib.d.ts',
    '/Users/…/node_modules/@types/node/globals.d.ts',
    '/Users/…/node_modules/@types/node/assert.d.ts',
    '/Users/…/node_modules/@types/node/async_hooks.d.ts',
    '/Users/…/node_modules/@types/node/buffer.d.ts',
    ... 1097 more items
  ]
}

[Info  - 9:07:28 AM] Connection to server got closed. Server will restart.
[Info  - 9:07:30 AM] Angular language server process ID: 68581
[Info  - 9:07:30 AM] Using typescript v3.7.4 from /Users/x/.vscode/extensions/angular.ng-template-0.900.12/node_modules/typescript/lib/tsserverlibrary.js
[Info  - 9:07:30 AM] Using @angular/language-service v9.0.1 from /Users/x/.vscode/extensions/angular.ng-template-0.900.12/server/node_modules/@angular/language-service/bundles/language-service.umd.js
[Info  - 9:07:30 AM] Log file: /Users/x/Library/Application Support/Code/logs/20200211T164224/exthost1/Angular.ng-template/nglangsvc.log

Setup
Angular CLI: 8.1.3
Node: 10.16.0
OS: darwin x64
Angular: 8.2.14

_Package Version_
@angular-devkit/architect 0.801.3
@angular-devkit/build-angular 0.801.3
@angular-devkit/build-optimizer 0.801.3
@angular-devkit/build-webpack 0.801.3
@angular-devkit/core 8.1.3
@angular-devkit/schematics 8.1.3
@angular/cdk 8.2.3
@angular/cli 8.1.3
@angular/flex-layout 8.0.0-beta.27
@angular/material 8.2.3
@ngtools/webpack 8.1.3
@schematics/angular 8.1.3
@schematics/update 0.801.3
rxjs 6.5.4
typescript 3.4.5
webpack 4.35.2

_VS Code_
Version: 1.42.0
Commit: ae08d5460b5a45169385ff3fd44208f431992451
Date: 2020-02-06T10:51:33.119Z
Electron: 6.1.6
Chrome: 76.0.3809.146
Node.js: 12.4.0
V8: 7.6.303.31-electron.0
OS: Darwin x64 18.7.0

bug extension

Most helpful comment

Well if you specify the paths for source files tsconfig should apply to it will only apply to those source files and nothing more. In the case of this issue, the relevant tsconfig path was "paths": {"@app/*": ["src/app/*"]"}, but the template source file is located at the nested path "src/app/test/test.component.html". If you get rid of the paths config option or expand it to include the nested file (e.g. via src/app/*/) the error should disappear. But for template files this should not affect the functionality of the language service.

All 32 comments

Can you provide the log file? Did you save test.component.html before this error occurred?

If you have @angular/language-service installed in your project, please uninstall it. This is likely due to the TS bug that prevents the bundled version from being loaded. Old versions of the @angular/language-service will attempt to load HTML files as TS sources and fail.

@kyliau How exactly would I go about finding that? Just enter @angular/language-service into extension search? Because nothing comes up there (so I guess I don't have it installed).

@ayazhafiz So the project setup has tests, prettier, rigorous linting and builds production all fine. And sure I'll press save from time to time. The whole projects works and even runs on a colleagues windows instance of vs code + this extionsion just fine :-/!

Here's the extension log:
nglangsvc.log

Btw I've redacted personal info and full directory output from the log (if you were wondering about some of the lines).

How exactly would I go about finding that? Just enter @angular/language-service into extension search?

I think Keen is referring to a @angular/language-service dependency in your package.json. Judging from your initial comment, you don't have this installed..

And sure I'll press save from time to time.

Sorry, what I mean is right before this crash happened, did the file you were working on exist on your disk/was saved to the disk? Recently we have had a lot of issues where people open a new file and begin editing it, but the file does not yet exist on the computer disk, and this causes problems inside the language service.

I have been able to repro the "config file not found" error, this is because of the paths specified in your tsconfig.. but I cannot repro the crash... any help would be appreciated here (@andrius-pra can you use your wizard repro skills? 🙂 )

@kyliau oh yes I have. Just uninstalled it. (But still at colleagues windows notebook it worked just fine even with the devdependency installed :-/)
--> Still same problem (different log error)! It doesn't like the hmtl files (as soon as I open the the components html file, ALS crashes again, .ts is fine).

[Info  - 5:28:42 AM] Angular language server process ID: 24893
[Info  - 5:28:42 AM] Using typescript v3.7.4 from /Users/x/.vscode/extensions/angular.ng-template-0.900.12/node_modules/typescript/lib/tsserverlibrary.js
[Info  - 5:28:42 AM] Using @angular/language-service v9.0.1 from /Users/x/.vscode/extensions/angular.ng-template-0.900.12/server/node_modules/@angular/language-service/bundles/language-service.umd.js
[Info  - 5:28:42 AM] Log file: /Users/x/Library/Application Support/Code/logs/20200217T052147/exthost1/Angular.ng-template/nglangsvc.log
/Users/x/.vscode/extensions/angular.ng-template-0.900.12/node_modules/typescript/lib/tsserverlibrary.js:131051
                throw error;
                ^
Error: Could not find source file: '/Users/x/Project/test/test.component.html'.
    at getValidSourceFile (/Users/x/.vscode/extensions/angular.ng-template-0.900.12/node_modules/typescript/lib/tsserverlibrary.js:131047:29)

@ayazhafiz

Sorry, what I mean is right before this crash happened, did the file you were working on exist on your disk/was saved to the disk? Recently we have had a lot of issues where people open a new file and begin editing it, but the file does not yet exist on the computer disk, and this causes problems inside the language service.

Yes it does. Even commited and pushed with no changes left hanging. I have no clue why it doesn't find the html files.

I have been able to repro the "config file not found" error, this is because of the paths specified in your tsconfig.. but I cannot repro the crash... any help would be appreciated here (@andrius-pra can you use your wizard repro skills? 🙂 )

Easy. Generate new app with https://ngx-rocket.com/

Do you open the HTML file before any TS file is open?

I just tried just having a couple .ts files open (ALS is fine then), but then as soon as I open the html it crashes

Strange. I created a ngx rocket project but still can't get the language service to crash. Any chance you can share a link to a repo that you see this happening in?

@ayazhafiz Are you on windows? As said, I only have this on my mac.

I'm on Mac

On Sun, Feb 16, 2020 at 9:49 PM ThaBrad notifications@github.com wrote:

Are you on windows? As said, I only have this on my mac.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/angular/vscode-ng-language-service/issues/635?email_source=notifications&email_token=AE6GL6S4WXVNIYZX3P7XEKLRDIQNRA5CNFSM4KVDKOD2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEL5EUGY#issuecomment-586828315,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AE6GL6TQ5DBZRFQP45V3D7LRDIQNRANCNFSM4KVDKODQ
.

Error: Could not find source file: '/Users/x/src/app/test/test.component.html'.
    at getValidSourceFile (/Users/x/.vscode/extensions/angular.ng-template-0.900.12/node_modules/typescript/lib/tsserverlibrary.js:131047:29)
    at Object.getSemanticDiagnostics (/Users/x/.vscode/extensions/angular.ng-template-0.900.12/node_modules/typescript/lib/tsserverlibrary.js:131269:36)
    at Object.proxy.getSemanticDiagnostics (/Users/x/node_modules/@angular/language-service/bundles/language-service.umd.js:49429:32)
    at Session.sendPendingDiagnostics (/Users/x/.vscode/extensions/angular.ng-template-0.900.12/server/index.js:1020:39)
    at Timeout._onTimeout (/Users/x/.vscode/extensions/angular.ng-template-0.900.12/server/index.js:1001:19)
    at listOnTimeout (internal/timers.js:531:17)
    at processTimers (internal/timers.js:475:7) {

@ThaBrad try to uninstall the @angular/language-service under /Users/x/, Or remove the node_modules.

@ivanwonder seems npm uninstall didn't fully remove the package or maybe something was cached. Anyways, now definitely removed, but still got that file not found error.

nglangsvc.log

Output
[Info - 10:11:01 AM] Log file: /Users/x/Library/Application Support/Code/logs/20200219T100635/exthost1/Angular.ng-template/nglangsvc.log
[Error - 10:11:27 AM] No config file for /Users/x/FE/src/app/test/test.component.html
[Error - 10:11:56 AM] Request textDocument/hover failed.
Message: Request textDocument/hover failed with message: Could not find source file: '/Users/x/FE/src/app/test/test.component.html'.
Code: -32603
[Error - 11:39:09 AM] Request textDocument/hover failed.
Message: Request textDocument/hover failed with message: Could not find source file: '/Users/x/FE/src/app/test/test.component.html'.
Code: -32603
[Error - 11:39:09 AM] Request textDocument/hover failed.
Message: Request textDocument/hover failed with message: Could not find source file: '/Users/x/FE/src/app/test/test.component.html'.
Code: -32603
[Error - 11:39:10 AM] Request textDocument/hover failed.
Message: Request textDocument/hover failed with message: Could not find source file: '/Users/x/FE/src/app/test/test.component.html'.
Code: -32603
[Error - 11:39:10 AM] Request textDocument/hover failed.
Message: Request textDocument/hover failed with message: Could not find source file: '/Users/x/FE/src/app/test/test.component.html'.
Code: -32603
[Error - 11:39:34 AM] Request textDocument/hover failed.
Message: Request textDocument/hover failed with message: Could not find source file: '/Users/x/FE/src/app/test/test.component.html'.
Code: -32603
[Error - 11:39:34 AM] Request textDocument/hover failed.
Message: Request textDocument/hover failed with message: Could not find source file: '/Users/x/FE/src/app/test/test.component.html'.
Code: -32603
[Error - 11:49:03 AM] Request textDocument/hover failed.
Message: Request textDocument/hover failed with message: Could not find source file: '/Users/x/FE/src/app/test/test.component.html'.
Code: -32603
[Error - 11:49:06 AM] Request textDocument/hover failed.
Message: Request textDocument/hover failed with message: Could not find source file: '/Users/x/FE/src/app/test/test.component.html'.
Code: -32603
/Users/x/.vscode/extensions/angular.ng-template-0.900.12/node_modules/typescript/lib/tsserverlibrary.js:131051
throw error;
^
Error: Could not find source file:……

(maybe another extension making problems?)

@ThaBrad When do you get the error file no found?

/Users/x/.vscode/extensions/angular.ng-template-0.900.12/node_modules/typescript/lib/tsserverlibrary.js:131051
throw error;
^

No more detail info here after the throw error?

@ivanwonder basically immediately
textDocument/hover failed. I of course get when I'm hovering over an element. (as so with textDocument/definition failed. when I Go To Definition)

No more detail info here after the throw error?

Sure ->
/Users/x/.vscode/extensions/angular.ng-template-0.900.12/node_modules/typescript/lib/tsserverlibrary.js:131051
throw error;
^

Error: Could not find source file: '/Users/x/FE/src/app/test/test.component.html'.
at getValidSourceFile (/Users/x/.vscode/extensions/angular.ng-template-0.900.12/node_modules/typescript/lib/tsserverlibrary.js:131047:29)
at Object.getSemanticDiagnostics (/Users/x/.vscode/extensions/angular.ng-template-0.900.12/node_modules/typescript/lib/tsserverlibrary.js:131269:36)
at Object.proxy.getSemanticDiagnostics (/Users/x/node_modules/@angular/language-service/bundles/language-service.umd.js:49429:32)
at Session.sendPendingDiagnostics (/Users/x/.vscode/extensions/angular.ng-template-0.900.12/server/index.js:1020:39)
at Timeout._onTimeout (/Users/x/.vscode/extensions/angular.ng-template-0.900.12/server/index.js:1001:19)
at listOnTimeout (internal/timers.js:531:17)
at processTimers (internal/timers.js:475:7) {
ProgramFiles: [……

at Object.proxy.getSemanticDiagnostics (/Users/x/node_modules/@angular/language-service/bundles/language-service.umd.js:49429:32)

Just try to remove /Users/x/node_modules/@angular/language-service dir.

The bundled language-service is at Users/x/.vscode/extensions/angular.ng-template-0.900.12/server/node_modules/@angular/language-service/bundles/language-service.umd.js

Dang it! @ivanwonder so sorry man.
After removing the devdependency from package.json and then rm -rf node_modulesand reinstalling it, it was there back again. I guess I there's some dependency that relies on it.

Anyways, I now just uninstalled npm uninstall @angular/language-service it and still got the file-not-found error, just without the any x/node_modules reference

[Info - 1:22:40 PM] Angular language server process ID: 20967
[Info - 1:22:40 PM] Using typescript v3.7.4 from /Users/x/.vscode/extensions/angular.ng-template-0.900.12/node_modules/typescript/lib/tsserverlibrary.js
[Info - 1:22:40 PM] Using @angular/language-service v9.0.1 from /Users/x/.vscode/extensions/angular.ng-template-0.900.12/server/node_modules/@angular/language-service/bundles/language-service.umd.js
[Info - 1:22:40 PM] Log file: /Users/x/Library/Application Support/Code/logs/20200219T132208/exthost1/Angular.ng-template/nglangsvc.log
[Error - 1:23:17 PM] No config file for /Users/x/FE/src/app/test/test.component.html
[Error - 1:23:17 PM] Request textDocument/hover failed.
Message: Request textDocument/hover failed with message: Could not find source file: '/Users/x/FE/src/app/test/test.component.html'.
Code: -32603

@ivanwonder and it's not like https://github.com/angular/vscode-ng-language-service/issues/437 where the path is incorrect. Path here is fine!

@ThaBrad Or try to change the version of @angular/language-service in package.json to 9.0.1.

@ivanwonder nah, still the same freaking error:
[Error - 1:58:56 PM] No config file for /Users/x/FE/src/app/test/test.component.html and therefore:

[Error - 2:09:38 PM] Request textDocument/hover failed.
  Message: Request textDocument/hover failed with message: Could not find source file: '/Users/x/FE/src/app/test/test.component.html'.
  Code: -32603 

FINNALY I got SOMEWHERE… 😤. Still weird and "errory"!

I saw in my system's user (mac -> /Users/myUser/) main folder I had a package.json & node_module folder with more or less the same stuff (and of course @angular/language-service). I found that out after uninstalling it from project/node_module's and the extension that it was still running.
WHY ON EARTH this path (totally out of any scope or reference / 5th-degree parent folder) was touched in any way bears absolutely no logic to me.
So I just deleted these artifacts and now I finally get stuff (hovering, autocomplete, …etc).

BUT:

  • still get the [Error - 2:50:55 PM] No config file for /Users/x/FE/src/app/test/test.component.html error for some reason (even if I also npm install @angular/language-service)
  • lost function of other extension (snippets primarily)
    now: Screenshot 2020-02-19 at 15 07 19 (and no, also not at bottom of list, just gone!)
    before: Screenshot 2020-02-19 at 15 12 32

.
.
.

(General) Editor fails

color coding

Also just in general, (installed) Angular Language Service is messing up the color coding in the editor in some cases (tag endings, directives and especially with html comments). That I also saw on other installations of colleagues VS Code instances

Screenshot 2020-02-19 at 15 32 10
Screenshot 2020-02-19 at 15 31 51
Screenshot 2020-02-19 at 15 38 05
(last one is just ALL

@kyliau, @ivanwonder, @ayazhafiz … should I put the color coding issues in a separate Issue and close this one?
(and we just ignore the no config file error?)

The color coding issues are known (#575) and will be closed soon (PR at #609). The no config file error makes sense given the tsconfig, and I think it should be fine -- you are still receiving language service features in that file, right?

The no config file error makes sense given the tsconfig, and I think it should be fine -- you are still receiving language service features in that file, right?

Don't get why this makes sense, but if you say so ;).
Yes extension now (seems to) works normally.

What about the missing snippets? (should I put it in a new issue?)

I don’t think the missing snippets should be related to the extension. Do they come back if you disable the extension? What are you using to get the snippets?

@ThaBrad @ayazhafiz I think the missing snippet is still related to the template color highlighting. remove the error color code, it will have snippets again.

I noticed this same error when investigating why angular intellisense started to act up. Is this an expected error? Could @ayazhafiz explain why this typescript relationship makes sense so that we all can be in the know.

Well if you specify the paths for source files tsconfig should apply to it will only apply to those source files and nothing more. In the case of this issue, the relevant tsconfig path was "paths": {"@app/*": ["src/app/*"]"}, but the template source file is located at the nested path "src/app/test/test.component.html". If you get rid of the paths config option or expand it to include the nested file (e.g. via src/app/*/) the error should disappear. But for template files this should not affect the functionality of the language service.

Closing this issue since the original causes appear to be resolved. If you observe additional problems, please file a new issue!

EVERYTHING fixed now

TO SUMMARIZE:

  • color coding fix by now (latest ALS extension version)
  • which also fixes the snippet problem
  • which also fixes the html comment problem

:white_check_mark: Original Problem fix: https://github.com/angular/vscode-ng-language-service/issues/635#issuecomment-588271261

awesome!

@ayazhafiz Thanks that helps clear things up for me.

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings