angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

Error in multi styles

Open hnguyenec opened this issue 10 years ago • 33 comments

OS?

Windows 7 x64

Versions.

Please run ng --version. If there's nothing outputted, please run in a Terminal: node --version and paste the result here:

angular-cli: 1.0.0.-beta.15 node: 4.4.7

Repro steps.

The app was created with angular-cli: ng new I added semantic.min.css under src/assets folder

in angular-cli.json, "apps" : [ { "styles": [ "../src/assets/sematic.min.css", "styles.css" ], } ]

The log given by the failure.

run: ng serve

ERROR in multi styles
Module not found: Error: Can't resolve 'c:\working\ng2\reddit\src\assets\sematic.min.css' in 'c:\working\ng2\reddit\node_modules\angular-cli\models'
@ multi styles

Mention any other details that might be useful.


hnguyenec avatar Sep 28 '16 23:09 hnguyenec

Paths in angular-cli.json are relative to the project root (src/ normally). For instance, you have the src/styles.css file, but in angular-cli.json it's listed only as styles.css.

filipesilva avatar Oct 06 '16 20:10 filipesilva

Have same issue.. Did you find any solution for this ?

RukGas avatar Jan 25 '17 10:01 RukGas

@filipesilva :thanks...it works. So the path in angular-cli.json references to src/. So if your path is some directory on same level as src say node_modules then in angular-cli.json reference the file as ../node_modules/

nilaysaha avatar Feb 13 '17 10:02 nilaysaha

@filipesilva Thanks that helped me fix my issue

lawmbass avatar Mar 17 '17 16:03 lawmbass

Another problem could be the missing of one of the styles. For example, if you have:

../node_modules/bootstrap/dist/css/bootstrap.min.css, ../node_modules/xxx/xxx/xxx.css, ../node_modules/yyy/yyy/yyy.css

And the xxx.css is missing - Error thrown will be Error in multi styles. Check the path for every module or asset.

djpysu avatar Mar 18 '17 12:03 djpysu

I had the same issue. But I have solved it. Main error is in the scripts and css which are coming from the 'node_modules' folder. Go to '.angular-cli.json' file and delete all 'node_modules' files and manually type the path of your all SCRIPTS and CSS ..

Thanks

devsubhajit avatar May 15 '17 06:05 devsubhajit

@shaadh Its really silly that copy/pasted path throws an error. I had seen your comment 3 hours ago, but dint try. Finally I thought to give it a try and boom. Thank You!

gulamabbas avatar Aug 17 '17 22:08 gulamabbas

I copy and pasted the bootstrap URL from another project that worked, but didn't work in my new project. Now fixed. node_module worked in the old project but in new project needed to be node_modules. In other words the folder structure was different for a new project to that of an old project, even though both were auto generated by Angular CLI.

A fix could be double checking that the URL you copied matches the location of the file you are referencing.

JustinZhaowilson avatar Aug 18 '17 04:08 JustinZhaowilson

If you have this error in angular and angular-cli You should use like below: "../node_modules/bootstrap/dist/css/bootstrap.css" Because your Index.html and .angular-cli.json files are not in the same folder!

ADoosti avatar Jun 05 '18 12:06 ADoosti

I had this problem but it was due to a simple typo in the angular.json - I had left "" as a style value in the projects architect build options styles.

It's a good job I spotted it as the error message in this instance is useless. Incidentally, I don't have angular-cli-json file in my project !

Bridgeway avatar Jul 17 '18 09:07 Bridgeway

Hello, I have this error, someone can help me? thanks ERROR in multi ../node_modules/bootstrap/dist/css/bootstrap.css ./src/styles.scss Module not found: Error: Can't resolve 'C:\Users\foued\node_modules\bootstrap\dist\css\bootstrap.css' in 'C:\Users\foued\mon-premier-projet'

fawzi2010 avatar Oct 31 '18 11:10 fawzi2010

Angular 7 needs style file’s relative path from main project folder, so in angular.json make sure all references to styles.scss include src/: "styles": [ "src/styles.scss" ],

Moreover, when you reference a npm package css/scss files in your styles.scss do it with ~ like so: @import '~font-awesome/scss/font-awesome';

meehol avatar Nov 06 '18 03:11 meehol

ERROR in multi ../node_modules/bootstrap/dist/css/bootstrap.min.css ./src/styles.css Module not found: Error: Can't resolve 'C:\xampp\htdocs\node_modules\bootstrap\dist\css\bootstrap.min.css' in 'C:\xampp\htdocs\Profile' i 「wdm」: Failed to compile. this error can occur in this bootstrap path...but when i change the path of bootstrap file then no error can occur. no error can occur with this path:- "node_modules/bootstrap/dist/css/bootstrap.min.css" Anyone can tell me the logic behind this why this happen??

mmamoonkhan avatar Nov 24 '18 09:11 mmamoonkhan

You gotta use path that’s relative from to the main folder of your project.

meehol avatar Nov 24 '18 16:11 meehol

I replaced this styles from angular.json "styles": ["src/styles.css"] to , "styles": ["styles.css"] It worked for me!

ManjunathCH12 avatar Dec 21 '18 07:12 ManjunathCH12

I think it is because of the problem with bootstrap, try this: Step 1. Inside .angular-cli.json file

"styles": [ "styles.css", "../node_modules/bootstrap/dist/css/bootstrap.min.css" ]

Remove "../node_modules/bootstrap/dist/css/bootstrap.min.css"

Step 2. Go to styles.css

Import bootstrap by adding this line @import "~bootstrap/dist/css/bootstrap.css";

These steps solved the errors I got during the building process.

kalikane avatar Jan 15 '19 22:01 kalikane

I solved in the following way. I am using Angular 7. During ng new my-app when prompted i took the sass option, as a result the style file was created with the name - styles.scss but what is referred in angular.json is styles.sass, I changed the extension to .scss in angular.json and boom, it's working now.

Hope it helps.

anmolsrepo avatar Feb 03 '19 00:02 anmolsrepo

@anmolsrepo: 👍 You saved me from wasting a day.

PradipShrestha avatar Feb 04 '19 20:02 PradipShrestha

Can we get this issue reopened? I also encountered the error on a clean install with v7.3

andygup avatar Feb 05 '19 18:02 andygup

Thank you @anmolsrepo . That fixed the problem.

kkuruva-rpx avatar Feb 05 '19 21:02 kkuruva-rpx