如何解决角度引导服务中的此错误代码?

时间:2019-05-19 00:03:17

标签: angular firebase bootstrap-4 angular7 angular-components

1-在“ app.compomnet.html”中,我使用入门模板代码 https://getbootstrap.com/docs/4.3/examples/starter-template/

2-我在终端中安装了bootsrap4“ npm I bootstap @ 4 --save”

3-我将此引用添加到style.css

4- in style.css '@ import'〜/ bootstrap / dist / css / bootstrap.css'

5-我试图输入' ng s --o ',发生此错误。

[![终端中的错误消息] [1]] [1] 2nd error message

我试图检查style.css中的代码是否正确 “ @ import'〜/ bootstrap / dist / css / bootstrap.css' 任何人都可以详细说明错误

[1]:第

行中的错误消息

./ src / styles.css(./node_modules/@angular-devkit/build-angular/src/angular-cli-files/plugins/raw-css-loader.js!../node_modules/postcss- loader / src ??嵌入!./ src / styles.css) 模块构建失败(来自./node_modules/postcss-loader/src/index.js): 错误:ENOENT:没有此类文件或目录,请打开“ \ bootstrap \ dist \ css \ bootstrap.css”     在Object.openSync(fs.js:438:3)     在Object.readFileSync(fs.js:343:35)     在Storage.provideSync(D:\购物车\ node_modules \ enhanced-resolve \ lib \ CachedInputFileSystem.js:98:13)     在CachedInputFileSystem.readFileSync(D:\ shopping-cart \ node_modules \ enhanced-resolve \ lib \ CachedInputFileSystem.js:259:32)     在Observable.rxjs_1.Observable.obs [作为_subscribe](D:\ shopping-cart \ node_modules @ ngtools \ webpack \ src \ webpack-input-host.js:35:51)     在Observable._trySubscribe(D:\ shopping-cart \ node_modules \ rxjs \ internal \ Observable.js:44:25)     在Observable.subscribe(D:\ shopping-cart \ node_modules \ rxjs \ internal \ Observable.js:30:22)     在SyncDelegateHost._doSyncCall(D:\ shopping-cart \ node_modules @ angular-devkit \ core \ src \ virtual-fs \ host \ sync.js:22:20)     在SyncDelegateHost.read(D:\ shopping-cart \ node_modules @ angular-devkit \ core \ src \ virtual-fs \ host \ sync.js:49:21)     在WebpackCompilerHost.readFileBuffer(D:\ shopping-cart \ node_modules @ ngtools \ webpack \ src \ compiler_host.js:125:44)     在VirtualFileSystemDecorator.readFile(D:\ shopping-cart \ node_modules @ ngtools \ webpack \ src \ virtual_file_system_decorator.js:39:54)     在Promise(D:\ shopping-cart \ node_modules @ angular-devkit \ build-angular \ src \ angular-cli-files \ models \ webpack-configs \ styles.js:47:35)     在新的Promise()     在Object.load(D:\ shopping-cart \ node_modules @ angular-devkit \ build-angular \ src \ angular-cli-files \ models \ webpack-configs \ styles.js:46:28)     在loadImportContent(D:\购物车\ node_modules \ postcss-import \ index.js:236:34)     在Promise.all.resolved.map.file(D:\ shopping-cart \ node_modules \ postcss-import \ index.js:210:18)[0m

2 个答案:

答案 0 :(得分:-1)

您需要将bootsrap添加到angular.json

// scroll down to the style section and add bootstrap line below
            "styles": [
              "src/styles.scss",
              "node_modules/bootstrap/dist/css/bootstrap.min.css"
            ],

答案 1 :(得分:-1)

Add this to your style.css

@import "~bootstrap/dist/css/bootstrap.css";