The error “Cannot find module ‘@angular/core'” usually occurs when there is any problem with the module resolution.
Here are some possible solutions that you can try to resolve this issue.

1. Look for the node_modules directory

If node_module folder is not present in project then install the dependencies using,
npm install

For yarn,
yarn install

2. Try installing manually

If node_module is already there then, try installing @angular/core manually using the following command;
npm install @angular/core

3. Restart IDE

Sometimes, VSCode needs to be restarted to recognize new modules and updates. Close all instances of VSCode and reopen your project.

4. Clear cache

In some cases, npm cache can cause the issue. So, try clearing it and reinstall dependencies using,
npm cache clean --force
npm install

For yarn,
yarn cache clean
yarn install

5. Delete node_modules and reinstall

Finally, if none of above works then delete node_modules, package-lock.json and reinstall the dependency using npm install

6. Check tsconfig.json file

Check that your tsconfig.json file is properly configured. Sometimes, VSCode fails to resolve the application base URL. As a result, IDE can’t resolve paths to imported components hence results in the error so you may want to set baseUrl option as “src”.

    "compilerOptions": {
        "baseUrl": "src",
        // other options...

7. Hard Reload Extensions

TypeScript IntelliSense or language service extensions in VS Code can sometimes lead to the error.
If auto-update is enabled for the TypeScript IntelliSense or Angular Language Service extensions, they may sometimes require a hard reload to function correctly.
To do this, follow the steps below:

  • Open the Command Palette using Ctrl+Shift+P.
  • Type Developer: Reload Window and select it to reload VS Code.
  • Alternatively, you can try disabling other extensions that might interfere with TypeScript or Angular support.

Support On Demand!