Error in WebStorm: TypeScript Compilation Error - "Cannot find module

I'm encountering an error in WebStorm while working on an Angular project. The TypeScript compiler is throwing the following error:

ERROR in ./src/app/app.component.ts
Module not found: Error: Can't resolve '@angular/core' in '/path/to/project/src/app'
 

The error occurs when trying to import modules from '@angular/core' or other Angular libraries.

Project Setup: Using Angular CLI for project setup and dependencies managed via npm.

I verified that '@angular/core' is listed in 'dependencies' in package.json.

  • Ran npm install to ensure all dependencies are up to date.
  • Checked TypeScript version and Angular CLI version compatibility.
  • Restarted WebStorm and cleared TypeScript cache using npm cache clean --force.
0
2 comments

Unfortunately I failed to reproduce the issue.

Please could you check if the node_modules/@angular/core folder is included in index? It would be helpful if you share a screenshot of the entire Project tool  window to demonstrate this folder and your whole project structure plus a screenshot of the error message.

 

0

"Have you tried deleting the node_modules folder and running npm install again? Sometimes a fresh install resolves dependency issues. Also, check if the @angular/core package is correctly installed by running npm list @angular/core. If the issue persists, ensure your Angular CLI and TypeScript versions are compatible by comparing them with Angular's official documentation. Hope this helps!"

0

Please sign in to leave a comment.