question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItĀ collects links to all the places you might be looking at while hunting down a tough bug.

And, if youā€™re still stuck at the end, weā€™re happy to hop on a call to see how we can help out.

Extension completely breaks when an Angular project is not the root directory of a workspace.

See original GitHub issue

šŸž bug report

Is this a regression?

Not as far as I can tell.

Description

While working with the ASP.NET Angular template, I noticed that VS Code constantly throws errors about bad syntax, missing imports, and, helpfully, things like saying ā€œAppears in the NgModule.imports of AppServerModule, but itself has errors(-996002)ā€, but then proceeding to show no other errors in the file (example in screenshots).

The Angular app compiles just fine, and these errors go away if I open the Angular app as the workspace directory.

Iā€™ve also been unable to reproduce this all of my machines; the problem seems to be sporadic but persistent. Iā€™ve also been unable to reproduce it in any other situations; it doesnā€™t seem to occur when I create a nested directory inside an empty directory and then open an Angular project in that nested directory.

Bug Type

What does this bug affect

  • Angular Language Service VSCode extension
  • Angular Language Service server

Reproduction

Steps to reproduce the behavior:

  1. Clone this repository: https://github.com/b4ux1t3/angular-extension-test.git
  • git clone https://github.com/b4ux1t3/angular-extension-test.git
  1. Run npm install inside the ClientApp directory.
  2. See the aforementioned errors.

Expected behavior

The extension should work regardless of where the angular project is within the VS Code workspace.

Logs

Iā€™m unable to generate logs, because the Angular compiler itself works just fine; it has no problem compiling and serving the application Iā€™m developing.

Screenshots

chrome_MtWtWNbAwl The aforementioned error.

image ngForm apparently doesnā€™t exist for forms, but you can see in the previous screenshot that I am, indeed, properly importing the FormsModule.

image This is a rather large screenshot, but you can see the broken extension on the left, with the same file pulled up in a VSCode instance with the angular application set as the workspace root, and the running, compiled application with no console errors on the right.

This is essentially the ā€œsmoking gunā€ that shows that the extension is the only thing misbehaving here.

šŸŒ Your Environment

Angular Version:



     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / ā–³ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 12.0.0
Node: 14.16.1
Package Manager: npm 7.20.5
OS: win32 x64

Angular:
...

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.1200.0 (cli-only)
@angular-devkit/core         12.0.0 (cli-only)
@angular-devkit/schematics   12.0.0 (cli-only)
@schematics/angular          12.0.0 (cli-only)

Extension Version:


v12.2.0

VSCode Version:


Version: 1.59.0 (user setup)
Commit: 379476f0e13988d90fab105c5c19e7abc8b1dea8
Date: 2021-08-04T23:13:12.822Z
Electron: 13.1.7
Chrome: 91.0.4472.124
Node.js: 14.16.0
V8: 9.1.269.36-electron.0
OS: Windows_NT x64 10.0.19043

Operating System:


Windows 10 Version 21H1 (OS Build 19043.1165)

Anything else relevant? Since I am running this as the client for a .NET application, VSCode is running (at least) three language servers:

  1. OmniSharp for C# and .NET
  2. Angular Language Service
  3. TypeScript

I donā€™t think that should matter, though.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9

github_iconTop GitHub Comments

1reaction
b4ux1t3commented, Aug 18, 2021

UPDATE: I upgraded the Angular version to 12.2.2, both in the application Iā€™m working on and the test project I pushed.

This seems to have resolved the issue, apologies for the false alarm! Iā€™m going to go open an issue on the .NET repo to get them to ship a supported version of Angular in their templates.

Thanks for the help @atscott!

0reactions
angular-automatic-lock-bot[bot]commented, Sep 18, 2021

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

VS Code breaks intellisense when working with multiple ...
The Angular application compiles just fine so it is only VS Code that does not understand the path and as a result I...
Read more >
Determine project root from a running node.js application
Try traversing upwards from __dirname until you find a package.json , and decide that's the app main root directory your current file belongs...
Read more >
Workspace and project file structure - Angular
The workspace root folder contains various support and configuration files, and a README file with generated descriptive text that you can customize.
Read more >
Angular 6 Workspace :: Test-Drive | by Matt Vaughn - Medium
Although the environment can use ng-packagr to build and output a library project to a dist folder completely ready for publishing - it...
Read more >
User and Workspace Settings - Visual Studio Code
Note: A VS Code "workspace" is usually just your project root folder. Workspace settings as ... Not all User settings are available as...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found