ASP.Net Core 2.1 with Angular Template - 无法更新 Bootstrap

ASP.Net Core 2.1 with Angular Template - Cannot update Bootstrap

当我创建一个新的 ASP.Net Core 2.1 项目时,选择 angular 模板,进入 package.json 并从默认版本更改 bootstrap 的版本号3 到版本 4(“4.0.0”等)然后它总是破坏我的应用程序。我已经尝试了很多东西,例如删除 node_modules 文件夹并重新安装它并尝试更新所有 bootstrap 的其他依赖项,但没有成功。

我希望能够将它更新到 4.0 版,以便我可以按照 bootstrap 主页上的代码示例进行操作。

这样做会破坏 angular 中的路由,因此不会加载任何页面并产生以下 BrowserslistError: Unknown browser major 错误。我试过更新浏览器列表,但没有成功。

有没有其他人尝试在 VS 2017 中创建一个新项目并选择 "ASP.Net Core 2.1 with Angular" 模板,然后尝试更新 bootstrap?有 "proper" 的方法吗?

webpack: Failed to compile.

Microsoft.AspNetCore.SpaServices:Error: ERROR in ./node_modules/bootstrap/dist/css/bootstrap.min.css
Module build failed: BrowserslistError: Unknown browser major
    at error (C:\Users\Anon\source\repos\WebApplication2\WebApplication2\ClientApp\node_modules\browserslist\index.js:37:11)
    at Function.browserslist.checkName (C:\Users\Anon\source\repos\WebApplication2\WebApplication2\ClientApp\node_modules\browserslist\index.js:320:18)
    at Function.select (C:\Users\Anon\source\repos\WebApplication2\WebApplication2\ClientApp\node_modules\browserslist\index.js:438:37)
    at C:\Users\Anon\source\repos\WebApplication2\WebApplication2\ClientApp\node_modules\browserslist\index.js:207:41
    at Array.forEach (<anonymous>)
    at browserslist (C:\Users\Anon\source\repos\WebApplication2\WebApplication2\ClientApp\node_modules\browserslist\index.js:196:13)
    at Browsers.parse (C:\Users\Anon\source\repos\WebApplication2\WebApplication2\ClientApp\node_modules\autoprefixer\lib\browsers.js:44:14)
    at new Browsers (C:\Users\Anon\source\repos\WebApplication2\WebApplication2\ClientApp\node_modules\autoprefixer\lib\browsers.js:39:28)
    at loadPrefixes (C:\Users\Anon\source\repos\WebApplication2\WebApplication2\ClientApp\node_modules\autoprefixer\lib\autoprefixer.js:56:18)
    at plugin (C:\Users\Anon\source\repos\WebApplication2\WebApplication2\ClientApp\node_modules\autoprefixer\lib\autoprefixer.js:62:18)
    at LazyResult.run (C:\Users\Anon\source\repos\WebApplication2\WebApplication2\ClientApp\node_modules\postcss-loader\node_modules\postcss\lib\lazy-result.js:277:20)
    at LazyResult.asyncTick (C:\Users\Anon\source\repos\WebApplication2\WebApplication2\ClientApp\node_modules\postcss-loader\node_modules\postcss\lib\lazy-result.js:192:32)
    at LazyResult.asyncTick (C:\Users\Anon\source\repos\WebApplication2\WebApplication2\ClientApp\node_modules\postcss-loader\node_modules\postcss\lib\lazy-result.js:204:22)
    at LazyResult.asyncTick (C:\Users\Anon\source\repos\WebApplication2\WebApplication2\ClientApp\node_modules\postcss-loader\node_modules\postcss\lib\lazy-result.js:204:22)
    at processing.Promise.then._this2.processed (C:\Users\Anon\source\repos\WebApplication2\WebApplication2\ClientApp\node_modules\postcss-loader\node_modules\postcss\lib\lazy-result.js:231:20)
    at new Promise (<anonymous>)
 @ multi ./src/styles.css ./node_modules/bootstrap/dist/css/bootstrap.min.css
ERROR in ./node_modules/bootstrap/dist/css/bootstrap.min.css
Module build failed: ModuleBuildError: Module build failed: BrowserslistError: Unknown browser major
    at error (C:\Users\Anon\source\repos\WebApplication2\WebApplication2\ClientApp\node_modules\browserslist\index.js:37:11)
    at Function.browserslist.checkName (C:\Users\Anon\source\repos\WebApplication2\WebApplication2\ClientApp\node_modules\browserslist\index.js:320:18)
    at Function.select (C:\Users\Anon\source\repos\WebApplication2\WebApplication2\ClientApp\node_modules\browserslist\index.js:438:37)
    at C:\Users\Anon\source\repos\WebApplication2\WebApplication2\ClientApp\node_modules\browserslist\index.js:207:41
    at Array.forEach (<anonymous>)
    at browserslist (C:\Users\Anon\source\repos\WebApplication2\WebApplication2\ClientApp\node_modules\browserslist\index.js:196:13)
    at Browsers.parse (C:\Users\Anon\source\repos\WebApplication2\WebApplication2\ClientApp\node_modules\autoprefixer\lib\browsers.js:44:14)
    at new Browsers (C:\Users\Anon\source\repos\WebApplication2\WebApplication2\ClientApp\node_modules\autoprefixer\lib\browsers.js:39:28)
    at loadPrefixes (C:\Users\Anon\source\repos\WebApplication2\WebApplication2\ClientApp\node_modules\autoprefixer\lib\autoprefixer.js:56:18)
    at plugin (C:\Users\Anon\source\repos\WebApplication2\WebApplication2\ClientApp\node_modules\autoprefixer\lib\autoprefixer.js:62:18)
    at LazyResult.run (C:\Users\Anon\source\repos\WebApplication2\WebApplication2\ClientApp\node_modules\postcss-loader\node_modules\postcss\lib\lazy-result.js:277:20)
    at LazyResult.asyncTick (C:\Users\Anon\source\repos\WebApplication2\WebApplication2\ClientApp\node_modules\postcss-loader\node_modules\postcss\lib\lazy-result.js:192:32)
    at LazyResult.asyncTick (C:\Users\Anon\source\repos\WebApplication2\WebApplication2\ClientApp\node_modules\postcss-loader\node_modules\postcss\lib\lazy-result.js:204:22)
    at LazyResult.asyncTick (C:\Users\Anon\source\repos\WebApplication2\WebApplication2\ClientApp\node_modules\postcss-loader\node_modules\postcss\lib\lazy-result.js:204:22)
    at processing.Promise.then._this2.processed (C:\Users\Anon\source\repos\WebApplication2\WebApplication2\ClientApp\node_modules\postcss-loader\node_modules\postcss\lib\lazy-result.js:231:20)
    at new Promise (<anonymous>)
    at runLoaders (C:\Users\Anon\source\repos\WebApplication2\WebApplication2\ClientApp\node_modules\webpack\lib\NormalModule.js:195:19)
    at C:\Users\Anon\source\repos\WebApplication2\WebApplication2\ClientApp\node_modules\loader-runner\lib\LoaderRunner.js:364:11
    at C:\Users\Anon\source\repos\WebApplication2\WebApplication2\ClientApp\node_modules\loader-runner\lib\LoaderRunner.js:230:18
    at context.callback (C:\Users\Anon\source\repos\WebApplication2\WebApplication2\ClientApp\node_modules\loader-runner\lib\LoaderRunner.js:111:13)
    at Promise.resolve.then.then.catch (C:\Users\Anon\source\repos\WebApplication2\WebApplication2\ClientApp\node_modules\postcss-loader\lib\index.js:189:71)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)

解决方案是使用不带 ^ 修饰符的 bootstrap 的特定测试版:

"bootstrap": "4.0.0-beta.2",

我希望这对遇到此问题的其他人有所帮助!

希望开发人员能尽快解决此问题。