0

Each time I open a new TypeScript file in an Angular project, it throws an error

Server angular-ls:xxxxx/starting exited with status exit(check corresponding stderr for details). Do you want to restart it? (y or n)

angular-ls:stderr buffer:

internal/modules/cjs/loader.js:638
    throw err;
    ^

Error: Cannot find module '/usr/lib/node_modules/@angular/language-server'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)

There isn't anything related to @angular/language-service left in package.json, yarn.lock or tsconfig.json but "something" keeps trying to start it.

Just to be clear, I don't want to disable TypeScript language service/LSP completely(it works fine you close this dialog), I just want to remove the artifacts of @angular/language-service.

How to fix it?

BinaryButterfly
  • 18,137
  • 13
  • 50
  • 91

2 Answers2

1

Not exactly an answer to the question posted, but an answer to a related question: how to fix the above error message. For me installing angular language server helped:

npm install -g @angular/language-service@next typescript @angular/language-server

(run in the project directory)

misiu_mp
  • 909
  • 1
  • 12
  • 17
0

After a bit of debugging: No need to disable it completely. You can just adjust the lsp-clients-angular-language-server-command instead.

If you have @angular/language-server installed locally(per project) the following elisp in your .dir-locals.el would solve the issue:

((nil
  (eval . (setq lsp-clients-angular-language-server-command
                (let ((curr-proj-root (projectile-project-root)))
                  `("node"
                    ,(concat curr-proj-root "node_modules/@angular/language-server")
                    "--ngProbeLocations"
                    ,(concat curr-proj-root "node_modules")
                    "--tsProbeLocations"
                    ,(concat curr-proj-root "node_modules")
                    "--stdio"))))))
BinaryButterfly
  • 18,137
  • 13
  • 50
  • 91
  • Could you shed more light on this, for instance how do I know if @angular/language-server is installed locally? I just followed some guides to make my emacs work with simple web-development (react) and simply pasted code into my .emacs. I dont know what most of it does (well, in detail). Now I start an angular project and get that. Its all very confusing. – misiu_mp Mar 02 '23 at 14:17