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
.
请先登录再写评论。
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."Have you tried deleting the
node_modules
folder and runningnpm install
again? Sometimes a fresh install resolves dependency issues. Also, check if the@angular/core
package is correctly installed by runningnpm 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!"