node_modules 在 AngularJS 2 [ng cli] 中没有 System.config

node_modules in AngularJS 2 [ng cli] without System.config

如何在没有 System.config 的情况下将 node_modules 包含在 AngularJS 2 个由 ng 生成的项目中?

尝试次数(src/index.html):

<link rel="stylesheet" href="./node_modules/bootstrap/dist/css/bootstrap.min.css">
<link rel="stylesheet" href="node_modules/bootstrap/dist/css/bootstrap.min.css">
<link rel="stylesheet" href="bootstrap/dist/css/bootstrap.min.css">
<link rel="stylesheet" href="dist/css/bootstrap.min.css">
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="bootstrap.min.css">

项目设置:

npm install -g angular2-cli
ng init
npm install
npm install --save bootstrap@4.0.0-alpha.5
npm start

注意:[默认情况下]文件树中既没有 systemjs.config.js 也没有任何对 System.config 的引用......

编辑:如果我包含的所有 node_modules 也被推入一个包中(例如:来自 ng build -prod),那就太好了。

要在您的构建中包含 node_module 资产,例如 css,您需要将其列在 angular-cli.json 中,如下所示:

{
  "apps": [
    {
      "styles": [
        "../node_modules/bootstrap/dist/css/bootstrap.css"
      ]
    }
  ]
}

另请参阅 angular-cli 自述文件 Global Library Installation

当您 运行 ng build -prod 时,cli 将捆绑列出的文件。