vscode-ng-language-service: Fail to detect older Angular projects < v9
🐞 bug report
Is this a regression?
Kinda, since the extension will not correctly detect the project’s Angular version and set the default setting to a proper value. A lot of developers will have this issue so that’s the main reason of this issue report.
Note: I’m actually working on a project whose Angular version can’t be updated at the moment.
Description
Latest extension release states:
Older projects will keep using View Engine language service.
By the way, it doesn’t seem to work, and it will raise the following error for older Angular projects:
Failed to resolve ngcc [...] Language service will remain disabled.
Bug Type
What does this bug affect
- Angular Language Service VSCode extension
- Angular Language Service server
Reproduction
- Open an Angular < v9 project (not sure about the version, personally I’m on v7)
- The
Failed to resolve ngcc
error will be displayed and the extension will not work
Expected behavior
The extension should be able to detect a pre-ivy project and automatically enable the angular.view-engine
setting.
“Temporary fix”
Set the angular.view-engine
workspace setting to true
.
Logs
Popup displayed:
Angular extension might not work correctly because ngcc operation failed. Try to invoke ngcc manually by running 'npm/yarn run ngcc'. Please see the extension output for more information.
🌍 Your Environment
Angular Version:
Angular CLI: 7.1.4
Node: 10.16.0
OS: win32 x64
Angular: 7.1.4
Extension Version:
v12.0.0
VSCode Version:
v1.56.1
Operating System:
Windows 10 Version 10.0.19042 Build 19042
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 17
- Comments: 15 (6 by maintainers)
Yeah, our goal is to make the extension detect the right Angular version, and pick the language service accordingly. There should be no manual configuration needed on the user’s side.
Meanwhile, if your project is using Angular < v9, you can explicitly tell the extension to use View Engine language service by checking the View Engine option in vscode Workspace settings (not User, as that’ll affect all projects):
@kyliau I think the problem is the default value. https://github.com/angular/vscode-ng-language-service/blob/ee741f8e90accd67326aff1c74d61e8181c7e473/package.json#L87 https://code.visualstudio.com/api/references/vscode-api#WorkspaceConfiguration Looks like the vscode treats it as
false
if I remove the default value.So if the config value is falsy, just use the value returned by checking the project’s angular version.
Thanks @ivanwonder for fixing the bug! We’ve published v12.0.1 with the fix, my sincere apologies for breaking users on older Angular versions.
In VSCode -> Workspace Settings -> Search View Engine -> Check checkbox Use legacy View Engine … -> clean node_modules -> run npm install
@nedex Could you please provide the logs? Also please double check your vscode config to make sure Ivy is turned off. To get the logs, please run the vscode command
Open Angular Server log
. The fact that you’re seeing the error messageFail to resolve ngcc...
means that the server is already spawned in Ivy mode, which should not happen. The client is responsible for detecting the Angular version of your project, and spawn the right server. We need more information to understand what’s going on. Thank you!I am also receiving this issue, report several modules, right after the Angular Language Service updated this morning:
export declare class NzRateModule { Appears in the NgModule.exports of NgZorroAntdModule, but could not be resolved to an NgModule, Component, Directive, or Pipe class.
This likely means that the library (ng-zorro-antd/slider) which declares NzSliderModule has not been processed correctly by ngcc, or is not compatible with Angular Ivy. Check if a newer version of the library is available, and update if so. Also consider checking with the library’s authors to see if the library is expected to be compatible with Ivy.
This likely means that the library (ng-zorro-antd/table) which declares NzTableModule has not been processed correctly by ngcc, or is not compatible with Angular Ivy. Check if a newer version of the library is available, and update if so. Also consider checking with the library’s authors to see if the library is expected to be compatible with Ivy.
Error: Error on worker #4: RangeError: Maximum call stack size exceeded Language service will remain disabled.