Search code examples
angulartypescript

How to fix MODULE_NOT_FOUND in Visual Studio while trying to run Standalone Typescript Angular project


I am attempting to create a Standalone Typescript Angular project in Visual Studio 2022 Community (17.8.0), but I am encountering the MODULE_NOT_FOUND error while running the project.

I installed 20.9.0 node version, also checked the folders, index.js and init.js are there.

How can I fix this?

enter image description here

I re-installed node, clean the project but still having this error.

UPDATE: I saw this message in the output window.

An exception happened at deploy, the port 4200 configured on launch.json is unavailable.

And here is the launch.json file

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "edge",
      "request": "launch",
      "name": "localhost (Edge)",
      "url": "http://localhost:4200",
      "webRoot": "${workspaceFolder}"
    },
    {
      "type": "chrome",
      "request": "launch",
      "name": "localhost (Chrome)",
      "url": "http://localhost:4200",
      "webRoot": "${workspaceFolder}"
    }
  ]
}

Solution

  • It's a known issue. https://developercommunity.visualstudio.com/t/Angular-and-ASPNET-Core-template-error:/10512806?sort=newes To temporary fix it, you should get an older version of angular

    npm install -g @angular/cli@v16-lts
    

    I will edit my answer when the fix is in place in upcoming releases.

    Edit: Get the latest Visual Studio update or (17.9.6) and the problem is fixed.