无法在角度2应用程序

时间:2018-01-12 18:57:22

标签: angular

I am trying to add the bootstrap class style.css file.When i am compiling the 
 application getting the below error.

的style.css

@import" ~bootstrap / dist / css / bootstrap.css&#34 ;;

**Myerror**
错误在./node_modules/css-loader?{"sourceMap" ;:false,"import" ;:false}!。/ node_modules / postcc-love / lib?{&# 34; IDENT":" postcss"" sourceMap":假} ./ SRC / styles.css的! 模块构建失败:错误:无法解析' ~bootstrap / dist / css / bootstrap.css'在' F:\ guna \ dreamapp \ src'     在onError(F:\ guna \ dreamapp \ node_modules \ enhanced-resolve \ lib \ Resolver.js:61:15)     在loggingCallbackWrapper(F:\ guna \ dreamapp \ node_modules \ enhanced-resolve \ lib \ createInnerCallback.js:31:19)     在runAfter(F:\ guna \ dreamapp \ node_modules \ enhanced-resolve \ lib \ Resolver.js:158:4)     在innerCallback(F:\ guna \ dreamapp \ node_modules \ enhanced-resolve \ lib \ Resolver.js:146:3)     在loggingCallbackWrapper(F:\ guna \ dreamapp \ node_modules \ enhanced-resolve \ lib \ createInnerCallback.js:31:19)     在下一个(F:\ guna \ dreamapp \ node_modules \ tapable \ lib \ Tapable.js:252:11)     在F:\ guna \ dreamapp \ node_modules \ enhanced-resolve \ lib \ UnsafeCachePlugin.js:40:4     在loggingCallbackWrapper(F:\ guna \ dreamapp \ node_modules \ enhanced-resolve \ lib \ createInnerCallback.js:31:19)     在runAfter(F:\ guna \ dreamapp \ node_modules \ enhanced-resolve \ lib \ Resolver.js:158:4)     在innerCallback(F:\ guna \ dreamapp \ node_modules \ enhanced-resolve \ lib \ Resolver.js:146:3)     在loggingCallbackWrapper(F:\ guna \ dreamapp \ node_modules \ enhanced-resolve \ lib \ createInnerCallback.js:31:19)     在下一个(F:\ guna \ dreamapp \ node_modules \ tapable \ lib \ Tapable.js:252:11)     在innerCallback(F:\ guna \ dreamapp \ node_modules \ enhanced-resolve \ lib \ Resolver.js:144:11)     在loggingCallbackWrapper(F:\ guna \ dreamapp \ node_modules \ enhanced-resolve \ lib \ createInnerCallback.js:31:19)     在下一个(F:\ guna \ dreamapp \ node_modules \ tapable \ lib \ Tapable.js:249:35)     at resolver.doResolve.createInnerCallback(F:\ guna \ dreamapp \ node_modules \ enhanced-resolve \ lib \ DescriptionFilePlugin.js:44:6)  @ ./src/styles.css 4:14-138  @ multi ./src/styles.css

2 个答案:

答案 0 :(得分:0)

这似乎是一个错误,Angular CLI 1.6.4暂时尝试回滚到1.6.3。

https://github.com/angular/angular-cli/issues/9080

答案 1 :(得分:0)

导入引导程序的路径中可能存在错误。我不知道从CSS直接导入它是否是一个好习惯,但这里是Angular CLI获取引导程序的方法:

npm install bootstrap@3 --save

然后在你的.angular-cli.json:

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

NB:如果您想使用Bootstrap 4 alpha,请安装它:

npm install bootstrap@4.0.0-beta.2 --save

然后要导入的JS文件的名称为bootstrap.bundle.min.js