如何解决 angular bootstrap ng serve 中的错误代码?
how can I solve this error code in angular bootstrap ng serve?
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]
我尝试检查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)
在承诺 (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-导入\index.js:210:18)[0m
您需要将引导程序添加到 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"
],
将此添加到您的 style.css
@import "~bootstrap/dist/css/bootstrap.css";
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]
我尝试检查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) 在承诺 (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-导入\index.js:210:18)[0m
您需要将引导程序添加到 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"
],
将此添加到您的 style.css
@import "~bootstrap/dist/css/bootstrap.css";