I was facing this issue only while importing my own created components/services
For those of you like me, for whom the accepted solution did not work, can try this:
Add
“baseUrl”: “src”
in your tsconfig.json. The reason is that visual code IDE is unable to resolve the base url so is unable to resolve path to imported components and gives error/warning.
Whereas angular compiler takes src as baseurl by default so it is able to compile.
NOTE:
You need to restart VS Code IDE to make this change come into effect.
EDIT:
As mentioned in one of the comments, in some cases changing workspace version might also work. More details here: https://github.com/Microsoft/vscode/issues/34681#issuecomment-331306869
Most likely missing node_modules package in the angular project, run:
npm install
inside the angular project folder.