Armineh
Armineh

Reputation: 96

Angular 13.3.4 : error module not found on the first ng serve -o

I am new in angularjs and I just install Node.js 16. After installation completed, I write this command

npm install -g @angular/cli

in the terminal of Visual Studio Code. by

ng --version

I checked Node.js, angular and typescript versions which is this.

Angular CLI: 13.3.4
Node: 16.15.0
typescript: 4.6.4

I generate my project ("frontend") with this code in visual studio terminal

ng new frontend

and then in frontend project I tried to run the project by this command ng serve -o but got error.

✔ Browser application bundle generation complete.

Initial Chunk Files | Names         |  Raw Size
vendor.js           | vendor        |   1.82 MB |
polyfills.js        | polyfills     | 123.33 kB |
main.js             | main          |  50.82 kB |
runtime.js          | runtime       |   6.34 kB |
styles.css          | styles        | 922 bytes |

                    | Initial Total |   2.00 MB

Build at: 2022-05-04T15:01:00.133Z - Hash: ee6d34bdbc610811 - Time: 3992ms

Error: Module not found: Error: Can't resolve '../frontend/src/app/app.component.css?ngResource' in '..\frontend'

Error: Module not found: Error: Can't resolve '..\frontend\node_modules\webpack-dev-server\client\index.js?protocol=auto%3A&username=&password=&hostname=0.0.0.0&port=0&pathname=%2Fws&logging=info&reconnect=10' in '..\frontend'

Error: The loader "../frontend/src/app/app.component.css" didn't return a string.

I did some search but I couldn't resolve my problem.

Upvotes: 5

Views: 1204

Answers (1)

Rick H
Rick H

Reputation: 41

I assume you've gotten past this, but others may not have.

This irritating and unhelpful message is generated when your component (.ts) file is requesting a style file with an extension different from the actual file (.css vs. .scss, for example).

Upvotes: 1

Related Questions