Angular : Module not found error after creating a project

Viewed 51

I have wiped my computer clean and when I reinstalled Node and angular and created a new project using routing and CSS and when I run the command ng serve I get this error.

>>>ng serve
√ Browser application bundle generation complete.

Initial Chunk Files | Names         |  Raw Size
vendor.js           | vendor        |   1.91 MB |
polyfills.js        | polyfills     | 109.52 kB |
main.js             | main          |  50.64 kB |
runtime.js          | runtime       |   6.34 kB |
styles.css          | styles        | 844 bytes |

                    | Initial Total |   2.07 MB

Build at: 2022-09-11T12:24:01.584Z - Hash: 2b9da3de59067827 - Time: 3310ms

Error: Module not found: Error: Can't resolve '<PROJECT_PATH>/project/src/app/app.component.css?ngResource' in '<PROJECT_PATH>\project'

Error: Module not found: Error: Can't resolve '<PROJECT_PATH>\project\node_modules\webpack-dev-server\client\index.js?protocol=auto%3A&username=&password=&hostname=0.0.0.0&port=0&pathname=%2Fng-cli-ws&logging=info&overlay=%7B%22errors%22%3Atrue%2C%22warnings%22%3Afalse%7D&reconnect=10&hot=false&live-reload=true' in '<PROJECT_PATH>\project'

Error: The loader "<PROJECT_PATH>/project/src/app/app.component.css" didn't return a string.



** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **


× Failed to compile.

I've enabled Windows Subsystem for Linux and installed Ubuntu then installed node and angular, but I get the same error.

1 Answers

You can try below steps ::

  1. Check if there is any issue related to npm version.
  2. Try installing npm and angular cli globally.
  3. Check environment path for ng module in system environment.
  4. Restart cmd terminal and do npm install again.

Hope this will help.

npm install -g @angular/cli
Related