angular / angular-cli

CLI tool for Angular
https://cli.angular.io
MIT License
26.73k stars 11.98k forks source link

ERROR in ./node_modules/css-loader?{"sourceMap":false,"importLoaders":1}!./node_ modules/postcss-loader/lib?{"ident":"postcss","plugins":[null,null,null],"source Map":false}!./node_modules/bootstrap/dist/css/bootstrap.css #9080

Closed unit11 closed 6 years ago

unit11 commented 6 years ago

Versions

<!--
Angular CLI: 1.5.5
Node: 8.9.1
OS: win32 x64
Angular: 5.1.2
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

@angular/cli: 1.5.5
@angular-devkit/build-optimizer: 0.0.36
@angular-devkit/core: 0.0.22
@angular-devkit/schematics: 0.0.42
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.8.5
@schematics/angular: 0.1.11
@schematics/schematics: 0.0.11
typescript: 2.4.2
webpack: 3.8.1

-->

Repro steps

styles.css ---> @import '~bootstrap/dist/css/bootstrap.css';

Observed behavior

ERROR in ./nodemodules/css-loader?{"sourceMap":false,"importLoaders":1}!./node modules/postcss-loader/lib?{"ident":"postcss","plugins":[null,null,null],"source Map":false}!./node_modules/bootstrap/dist/css/bootstrap.css Module build failed: BrowserslistError: Unknown browser major at error (D:\angular\organicShop\node_modules\browserslist\index.js:37:11) at Function.browserslist.checkName (D:\angular\organicShop\node_modules\brow serslist\index.js:320:18) at Function.select (D:\angular\organicShop\node_modules\browserslist\index.j s:438:37) at D:\angular\organicShop\node_modules\browserslist\index.js:207:41 at Array.forEach () at browserslist (D:\angular\organicShop\node_modules\browserslist\index.js:1 96:13) at Browsers.parse (D:\angular\organicShop\node_modules\autoprefixer\lib\brow sers.js:44:14) at new Browsers (D:\angular\organicShop\node_modules\autoprefixer\lib\browse rs.js:39:28) at loadPrefixes (D:\angular\organicShop\node_modules\autoprefixer\lib\autopr efixer.js:56:18) at plugin (D:\angular\organicShop\node_modules\autoprefixer\lib\autoprefixer .js:62:18) at LazyResult.run (D:\angular\organicShop\node_modules\postcss-loader\node_m odules\postcss\lib\lazy-result.js:277:20) at LazyResult.asyncTick (D:\angular\organicShop\node_modules\postcss-loader\ node_modules\postcss\lib\lazy-result.js:192:32) at LazyResult.asyncTick (D:\angular\organicShop\node_modules\postcss-loader\ node_modules\postcss\lib\lazy-result.js:204:22) at processing.Promise.then._this2.processed (D:\angular\organicShop\node_mod ules\postcss-loader\node_modules\postcss\lib\lazy-result.js:231:20) at new Promise () at LazyResult.async (D:\angular\organicShop\node_modules\postcss-loader\node _modules\postcss\lib\lazy-result.js:228:27) @ ./node_modules/css-loader?{"sourceMap":false,"importLoaders":1}!./node_module s/postcss-loader/lib?{"ident":"postcss","sourceMap":false}!./src/styles.css 3:10 -186 @ ./src/styles.css @ multi ./src/styles.css

dcatoday commented 6 years ago

I am seeing this issue but my project doesn't use bootstrap.

vinayakvinay commented 6 years ago

Facing the same issue as mentioned above. with Angular CLI 1.6,

"@ng-bootstrap/ng-bootstrap": "^1.0.0-beta.8",
"bootstrap": "^4.0.0-beta.3",
vinayakvinay commented 6 years ago

Duplicate: @unit11 refer this thread https://github.com/angular/angular-cli/issues/9020

clydin commented 6 years ago

Closing as a duplicate of #9020.

unit11 commented 6 years ago

Actually the problem is not happening for "bootstrap": "4.0.0-beta.2", so I have to shift to "bootstrap": "4.0.0-beta.3" in order to continue the project.I have updated the "^bootstrap": "4.0.0-beta.3" in th package.json file and run "npm install" and "ng serve".The problem is not happening in that case.

Package.json

{ "name": "sample-project", "version": "0.0.0", "license": "MIT", "scripts": { "ng": "ng", "start": "ng serve", "build": "ng build", "test": "ng test", "lint": "ng lint", "e2e": "ng e2e" }, "private": true, "dependencies": { "@angular/animations": "^5.0.0", "@angular/common": "^5.0.0", "@angular/compiler": "^5.0.0", "@angular/core": "^5.0.0", "@angular/forms": "^5.0.0", "@angular/http": "^5.0.0", "@angular/platform-browser": "^5.0.0", "@angular/platform-browser-dynamic": "^5.0.0", "@angular/router": "^5.0.0", "bootstrap": "4.0.0-beta.2", "core-js": "^2.4.1", "rxjs": "^5.5.2", "zone.js": "^0.8.14" }, "devDependencies": { "@angular/cli": "1.5.5", "@angular/compiler-cli": "^5.0.0", "@angular/language-service": "^5.0.0", "@types/jasmine": "~2.5.53", "@types/jasminewd2": "~2.0.2", "@types/node": "~6.0.60", "codelyzer": "^4.0.1", "jasmine-core": "~2.6.2", "jasmine-spec-reporter": "~4.1.0", "karma": "~1.7.0", "karma-chrome-launcher": "~2.1.1", "karma-cli": "~1.0.1", "karma-coverage-istanbul-reporter": "^1.2.1", "karma-jasmine": "~1.1.0", "karma-jasmine-html-reporter": "^0.2.2", "protractor": "~5.1.2", "ts-node": "~3.2.0", "tslint": "~5.7.0", "typescript": "~2.4.2" } }

npm install

ng serve

maa105 commented 6 years ago

this is related to:

9061

I spent all day trying to fix it tried ~, ../node_modules, I defined a path @node_modules in "paths" in compilerOptions in tsconfig.json and used it nothing seems to work, so I reverted back to cli 1.5.5 but it required @angular/service-worker version to satisfy >= 1.0.0-beta.5 < 2.0.0 which I already updated to version 5.1.2, please help I'm stuck

maa105 commented 6 years ago

Im also getting some wierd mixup in the path characters:

Module not found: Error: Can't resolve './....node_modules☼ont-awesome☼onts☼ontawesome-webfont.eot' in 'c:\Users\\Desktop\\src' resolve './....node_modules☼ont-awesome☼onts☼ontawesome-webfont.eot' in 'c:\Users\\Desktop\\src'

it seems everything after the / is either missing or is using some kind of escape sequence like "/f" in "/fontawesome" is displaying as "☼"

same thing with ionic icons:

Module not found: Error: Can't resolve './....node_modulesionic-angular☼ontsnoto-sans-bold.woff' in 'c:\Users\\Desktop\\src' resolve './....node_modulesionic-angular☼ontsnoto-sans-bold.woff' in 'c:\Users\\Desktop\\src'

any ideas?

vinayakvinay commented 6 years ago

Use Bootstrap beta 2 instead.

myspivey commented 6 years ago

I just updated to the latest CLI on a Mac machine and am now getting this. Our project does not use Bootstrap in any aspect.

dharders commented 6 years ago

@myspivey Yeah I had the same experience. I don't use bootstrap either.

Downgrading to "@angular/cli": "1.6.3" fixed it for me. i.e. something changed in 1.6.4.

billdwhite commented 6 years ago

@myspivey same here: went to 1.6.4 and started getting this

skiabox commented 6 years ago

The problem is not bootstrap related. I get the same error when I am trying to use

@import "~@angular/material/prebuilt-themes/indigo-pink.css";

inside styles.css. That means that I cannot use angular material components!

Shadowlauch commented 6 years ago

I don't seem to be able to successfully import any css file in node_modules. Neither by using a relative path nor by using the ~. Imports that are in my application itself can be imported.

@import '~angular-tree-component/dist/angular-tree-component.css'; doesn't work

@import url('../../../../node_modules/font-awesome/css/font-awesome.min.css'); doesn't work

@import url('./sidebar.css'); this works

huiaic commented 6 years ago

If you are not using bootstrap then it's due to another open bug - #9185

SerafimovichEugene commented 6 years ago

Had the same issue. I temporary inserted all global .css to .angular-cli.json. Builds fine.

...
"styles": [
        "styles.css",
        "../node_modules/font-awesome/css/font-awesome.css",
        "../node_modules/@angular/material/prebuilt-themes/deeppurple-amber.css",
        "../node_modules/material-design-icons/iconfont/material-icons.css"
      ],
...
hassansw commented 6 years ago

change it to: @import "@angular/material/prebuilt-themes/indigo-pink.css";

by removing ~ fixed my problem

jguingo commented 6 years ago

i had the same issue but solved when i've set @import 'bootstrap/dist/css/bootstrap.css'; instead of @import '~bootstrap/dist/css/bootstrap.css';

in the style.css , same solution as hassansw

FabianAlvaradoDotCom commented 6 years ago

@hassansw , It worked just fine! Thanks

By the way, it happened when I imported indigo theme: @import "~@angular/material/prebuilt-themes/indigo-pink.css";

Removing the '~' saved my life.

tiandiduwuxiaoxiao commented 6 years ago

Hi @SerafimovichEugene , I have the same issue and can't solve it although I try all methods I know. I inserted bootstrap global .css to .angular.cli.json, like below but build failed:

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

Any ideas for the issue mentioned above? Thanks advance for your help.

IK-Hwan commented 6 years ago

@import "@angular/material/prebuilt-themes/indigo-pink.css";

remove '~'

ghost commented 6 years ago

(Working with Angular CLI 1.6.4 and Angular 5.2.1) I was @importing "../node_modules/material-design-icons/iconfont/material-icons.css" in my main stylesheet. I removed the @import and instead referenced this stylesheet in .angular-cli.json and it solved my problem.

jeness commented 6 years ago

I donpm install for redeployment for my project. I have the same issue too. I use ng-v to see if it is about version of angular-cli. I find out the version is 1.6.4 now. But I have stated in package.json that the version of angular-cli should be 1.4.3. So I just downgrade the angular-cli. npm install @angular/cli@1.4.3 And this build error solved. May be this solution is not very smart enough. But it works for my project.

JoseRFJuniorLLMs commented 6 years ago

{ "name": "projeto-final", "version": "0.0.0", "license": "MIT", "scripts": { "ng": "ng", "start": "ng serve", "build": "ng build", "test": "ng test", "lint": "ng lint", "e2e": "ng e2e" }, "private": true, "dependencies": { "@angular/common": "^5.0.0", "@angular/compiler": "^5.0.0", "@angular/core": "^5.0.0", "@angular/forms": "^5.0.0", "@angular/http": "^5.0.0", "@angular/platform-browser": "^5.0.0", "@angular/platform-browser-dynamic": "^5.0.0", "@angular/router": "^5.0.0", "bootstrap": "^4.0.0", "core-js": "^2.4.1", "jquery": "^3.2.1", "rxjs": "^5.1.0", "zone.js": "^0.8.5", "@angular-devkit/core": "0.0.28", "@angular/animations": "^5.0.0", "bluebird": "^3.5.1", "body-parser": "^1.18.2", "express": "^4.16.2", "mongoose": "^4.13.1", "morgan": "^1.9.0", "serve-favicon": "^2.4.5" }, "devDependencies": { "@angular/cli": "1.6.4", "@angular/compiler-cli": "^5.0.0", "@types/jasmine": "~2.5.53", "@types/node": "~6.0.60", "codelyzer": "~3.2.0", "jasmine-core": "~2.6.2", "jasmine-spec-reporter": "~4.1.0", "karma": "~1.7.0", "karma-chrome-launcher": "~2.1.1", "karma-cli": "~1.0.1", "karma-jasmine": "~1.1.0", "karma-jasmine-html-reporter": "^0.2.2", "karma-coverage-istanbul-reporter": "^1.2.1", "protractor": "~5.1.2", "ts-node": "~3.2.0", "tslint": "~5.7.0", "typescript": "~2.4.2", "@angular/language-service": "^5.0.0", "@types/jasminewd2": "~2.0.2" } }

HalShaw commented 6 years ago

Angular4, ng build, same with this issue, not bootstrap, it's about icheck.

ERROR in ./node_modules/css-loader?{"sourceMap":false,"import":false}!./node_modules/postcss-loader/lib?{"ident":"postcss","sourceMap":false}!./node_modules/icheck/skins/all.css Module build failed: Error: Can't resolve 'minimal/_all.css' in 'E:\workflow-manager\workflow-frontend\node_modules\icheck\skins'.

I'm developing angular app, when I run ng build, this error showed up. Don't konw it's a bug or not, is there any ideas? Thanks.

sean-olson-e commented 6 years ago

I implemented it same as @tiandiduwuxiaoxiao in the global css -- getting the same error. If I move the bootstrap.css file to the root of the node modules folder

"styles": [ "styles.css", "../node_modules/bootstrap.css" ], or anywhere else above the node_modules directory, no problem. Seems like a problem with traversing the directory tree.

usman10scorpio commented 6 years ago
"bootstrap": "4.0.0-beta.2",

worked for me 👍

pratikpawarnasik commented 6 years ago

I have same issue using both of bootstrap versions

sathishkanda123 commented 6 years ago

I dont know , what the issue is your facing but in mine , i tried with refering stack overflow npm uninstall -g angular-cli npm cache clean or npm cache verify (if npm > 5) npm install -g @angular/cli@latest rm -rf node_modules npm uninstall --save-dev angular-cli npm install --save-dev @angular/cli@latest npm install and including my css by removing tilde sign (~nodemodules/..css to ../nodemodules/...css )

SelormBruce commented 5 years ago

npm install worked for me

thilinisevwandi commented 5 years ago

You have to update node.js and angular/cli.Then you have angular.json file instead of angular-cli.json file.Then you add css file into angular.json file.If youn add css file into angular-cli.json file ,errors are occured.

angular-automatic-lock-bot[bot] commented 5 years ago

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.