为angular 4 cli安装bootstrap时出错

时间:2018-01-26 13:59:05

标签: angular bootstrap-4

当我尝试在angular4 cli(windows)中安装bootstrap时,会发生以下错误

npm install bootstrap --save

  

npm WARN可选SKIPPING OPTIONAL DEPENDENCY:fsevents@1.1.3(node_modules \ fsevents):   npm WARN notsup SKIPPING OPTIONAL DEPENDENCY:不支持的fsevents@1.1.3平台:想要{" os":" darwin"," arch":"任何& #34;}(当前:{" os":" win32"," arch":" x64"})

2 个答案:

答案 0 :(得分:0)

如果您可以在父bootstrap文件夹中找到node_modules文件夹,则知道是否正确安装了引导程序。如果你还没有,我也会尝试这个:

  1. 安装Bootstrap npm install --save bootstrap
  2. 将Bootstrap导入

    • styles.css使用@import "~bootstrap/dist/css/bootstrap.css";
    • .angular-cli.json通过styles属性:

      "styles": [ "styles.css", "../node_modules/bootstrap/dist/css/bootstrap.css" ],

答案 1 :(得分:0)

使用这些命令对我有用

npm install bootstrap

然后将其包含在angular.json

"styles": [
              "./node_modules/bootstrap/dist/css/bootstrap.min.css",
              "src/styles.css"
            ],
            "scripts": [
              "./node_modules/jquery/dist/jquery.js",
              "./node_modules/popper.js/dist/umd/popper.min.js",
              "./node_modules/bootstrap/dist/js/bootstrap.js"
            ]