vscode-ng-language-service: The LS does not recognise components as being standalone

🐞 bug report

Description

Since Angular 19, components are standalone by default. However, the LS does not seems to take that into account. I’ve migrated my Angular app to Angular 19 so now all my components does not have anymore the standalone: true line but this cause errors to appears in every template and in every imports: [] because the LS does not consider my components to be standalone.

ps: I don’t use VSCode but I use Neovim.

Bug Type

What does this bug affect

  • Angular Language Service VSCode extension
  • Angular Language Service server

Reproduction

Steps to reproduce the behavior:

  1. Create a new Angular project
  2. Migrate the project to Angular 19
  3. See the error in app.component.ts saying that ‘imports’ is only valid on a component that is standalone.

Expected behavior

No error should appear.

Screenshots

Image

Image

🌍 Your Environment

Angular Version:


Angular CLI: 19.0.0
Node: 20.14.0
Package Manager: npm 10.9.0
OS: darwin arm64

Angular: 19.0.0
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1900.0
@angular-devkit/build-angular   19.0.0
@angular-devkit/core            19.0.0
@angular-devkit/schematics      19.0.0
@schematics/angular             19.0.0
rxjs                            7.8.1
typescript                      5.5.4
zone.js                         0.15.0

Extension Version:


v19.0.2

Operating System:


macOS Sequoia : 15.0.1

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 16
  • Comments: 27 (3 by maintainers)

Most upvoted comments

@spock123 But you can do a global find & replace to change any:

@Component({

To:

@Component({
    standalone: true,

It takes like 30 seconds to do so.

The issue still persists in VS code with Angular Language Service 19.0.3

Same issue here.

a new version of @angular/language-server has been published now, so everything should work fine now.

I was also having the issue in neovim/mason. I tried uninstalling/reinstall/update, but that didn’t work. However, I found a temporary solution. The problem was that the language service was set to a next/preview build, not the most recent build. The angular server was set to the latest version, but the angular service (a dependency of the server) was on an outdated version.

cd ~/.local/share/nvim/mason/packages/angular-language-server (or the windows equivalent) Open the package-lock.json folder. Scroll to the @angular/language-server section and examine the dependencies. Mine showed that @angular/language-service was set to 19.0.0-next.6

It should be v19.0.1. (note that the latest version of the language server is 19.0.2, but the latest of the service is 19.0.1).

Change the version of the dependencies to be v19.0.1.

    "node_modules/@angular/language-server": {
      "version": "19.0.2",
      "resolved": "https://registry.npmjs.org/@angular/language-server/-/language-server-19.0.2.tgz",
      "integrity": "sha512-vXDgGgSEzkgftr0+6u88uJr2ic62+fofN2r/G5KNp1CaZoI2zKZWSIo5ZpndIIaanAWaHWMIO8D50Ze2YM69DA==",
      "license": "MIT",
      "dependencies": {
        "@angular/language-service": "19.0.1", // This line was changed -------------------------------
        "vscode-html-languageservice": "^4.2.5",
        "vscode-jsonrpc": "6.0.0",
        "vscode-languageserver": "7.0.0",
        "vscode-languageserver-textdocument": "^1.0.7",
        "vscode-uri": "3.0.7"
      },
      "bin": {
        "ngserver": "bin/ngserver"
      },
      "engines": {
        "node": "^18.19.1 || ^20.11.1"
      }
    },

Scroll down to the language-service section. Change its version and URL to be the 19.0.1. Remove the integrity check if one is listed. I don’t know how to get the new integrity check, but if you know how to locate that then you could replace it.

    "node_modules/@angular/language-server/node_modules/@angular/language-service": {
      "version": "19.0.1", // This line was changed ------------
      "resolved": "https://registry.npmjs.org/@angular/language-service/-/language-service-19.0.1.tgz",  // This line was changed ------------
      "license": "MIT",
      "engines": {
        "node": "^18.19.1 || ^20.11.1 || >=22.0.0"
      }
    },

Finally, run npm i

Everything is working now, but I’m guessing that a package update by mason would break it. I would like an easier fix than this, but this was enough for the moment.

Did anybody find any workarounds?

Encountering the same issue in Neovim as well (also using Mason).

I am experiencing this issue as well after updating my Nx monorepo to v19. VSCode extension version 19.0.2.

this has caused issues with projects using a version older than Angular 19, now. It incorrectly detects which angular is being used in the project and tells you that your components are standalone when they’re not. Now I need to explicitly add standalone: false to all of my components to remove errors that are not actually errors.

We are getting the same issue and uninstalling does not fix the problem … so I just set standalone: true as workaround. Not ideal but better than getting the error.

We are using the vscode workspace feature.

@Ask-786 Beautiful, works here also! Wonderful! Cheers

@devversion For Neovim, the issue was related about how Mason manages the language server. The language server was set to use the language service v19.0.0-next.6 instead of the v19.0.1. So I guess we should open an issue in the Mason GitHub repo.

For VSCode I don’t know since I’m not using it.

I don’t know what the state of this issue is, but:

  • @angular/language-server does point to the latest Angular v19 version at this point
  • the latest language service version, released when v19 came out, should work.

I suspect the issue most people are seeing here is that the VSCode extension picks one version of a e.g. monorepo. So, if you have e.g. Angular v18 somewhere in your project, the extension will use and treat the lack of standalone: true as standalone: false— like it was the case with v18. Can someone with the problem verify this?

The logic is not great, so this could serve as a tracking issue, but we should verify this is the problem first.