我在npm cli中安装了jquery,popper.js和bootstrap。安装完成后,我在angularcli.json中为bootstrap添加了样式引用。当我运行该项目时,显示以下错误。请帮忙。
ERROR in ./~/css-loader?{"sourceMap":false,"importLoaders":1}!./~/postcss-loader?{"ident":"postcss"}!./~/bootstrap/dist/css/bootstrap.min.css
Module build failed: BrowserslistError: Unknown browser major
at error (C:\Users\hasan\angulartest\boottest\node_modules\browserslist\index.js:37:11)
at Function.browserslist.checkName (C:\Users\hasan\angulartest\boottest\node_modules\browserslist\index.js:320:18)
at Function.select (C:\Users\hasan\angulartest\boottest\node_modules\browserslist\index.js:438:37)
at C:\Users\hasan\angulartest\boottest\node_modules\browserslist\index.js:207:41
at Array.forEach (native)
at browserslist (C:\Users\hasan\angulartest\boottest\node_modules\browserslist\index.js:196:13)
at Browsers.parse (C:\Users\hasan\angulartest\boottest\node_modules\autoprefixer\lib\browsers.js:44:14)
at new Browsers (C:\Users\hasan\angulartest\boottest\node_modules\autoprefixer\lib\browsers.js:39:28)
at loadPrefixes (C:\Users\hasan\angulartest\boottest\node_modules\autoprefixer\lib\autoprefixer.js:56:18)
at plugin (C:\Users\hasan\angulartest\boottest\node_modules\autoprefixer\lib\autoprefixer.js:62:18)
at LazyResult.run (C:\Users\hasan\angulartest\boottest\node_modules\postcss\lib\lazy-result.js:274:20)
at LazyResult.asyncTick (C:\Users\hasan\angulartest\boottest\node_modules\postcss\lib\lazy-result.js:189:32)
at LazyResult.asyncTick (C:\Users\hasan\angulartest\boottest\node_modules\postcss\lib\lazy-result.js:201:22)
at processing.Promise.then._this2.processed (C:\Users\hasan\angulartest\boottest\node_modules\postcss\lib\lazy-result.js:228:20)
at LazyResult.async (C:\Users\hasan\angulartest\boottest\node_modules\postcss\lib\lazy-result.js:225:27)
at LazyResult.then (C:\Users\hasan\angulartest\boottest\node_modules\postcss\lib\lazy-result.js:131:21)
@ ./~/bootstrap/dist/css/bootstrap.min.css 4:14-127
@ multi ./~/bootstrap/dist/css/bootstrap.min.css ./src/styles.css
答案 0 :(得分:0)
这看起来像是某种相关的问题 请看这个:
- 从“bootstrap”:“^ 4.0.0-beta.2”到“bootstrap”:“4.0.0-beta.2”,取出“^”强>
- 然后 npm install
- 然后 ng服务
答案 1 :(得分:0)
似乎bootstrap版本4有bug。我在packages.json中将bootstraps版本从4.0.0更改为3.0.0并运行命令npm install。之后一切正常。