【问题标题】:how can I solve this error code in angular bootstrap ng serve?如何在 angular bootstrap ng serve 中解决此错误代码?
【发布时间】:2019-10-05 19:27:25
【问题描述】:

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

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

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

4- 在 style.css '@import'~/bootstrap/dist/css/bootstrap.css'

5- 我尝试输入 'ng s --o' 这个错误发生了。

[![终端中的错误消息][1]][1]

我尝试检查 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??embedded!./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:\shopping-cart\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 [as _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) 在新的承诺 () 在 Object.load (D:\shopping-cart\node_modules@angular-devkit\build-angular\src\angular-cli-files\models\webpack-configs\styles.js:46:28) 在 loadImportContent (D:\shopping-cart\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

【问题讨论】:

  • 请复制并粘贴错误文本,而不是提供屏幕截图。搜索引擎不会抓取图片中的文字,因此人们不太可能找到您的问题。

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


【解决方案1】:

将此添加到您的 style.css

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

【讨论】:

    【解决方案2】:

    你需要将 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"
                ],
    

    【讨论】:

    • 是的..这是解决方案..但是为什么这是正确的..或者当我向下滚动并将其放在下面时..这是解决方案。您能详细说明吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多