0

我知道这个问题被问了大约 100 次,但我收到了这个错误。请检查屏幕截图。

错误:SyntaxError: Unexpected token < at Object.eval ( http://localhost:3000/node_modules/ng2-bootstrap/components/datepicker/date-formatter.js:2:14 ) at eval ( http://localhost:3000 /node_modules/ng2-bootstrap/components/datepicker/date-formatter.js:13:4 ) 评估http://localhost:3000/moment 评估http://localhost:3000/node_modules/ng2-bootstrap/components/datepicker/ date-formatter.js 评估http://localhost:3000/node_modules/ng2-bootstrap/components/datepicker/datepicker-inner.js 评估http://localhost:3000/node_modules/ng2-bootstrap/components/datepicker/datepicker。 js 评估http://localhost:3000/node_modules/ng2-bootstrap/components/datepicker/datepicker-popup.js 评估http://localhost:3000/node_modules/ng2-bootstrap/components/datepicker.js 评估http://localhost: 3000/node_modules/ng2-bootstrap/ng2-bootstrap.js 加载http://localhost:3000/app/main.js 时出错

我遵循了为修复系统配置而给出的解决方案

System.config({
        packages: {
          app: {
            format: 'register',
            defaultExtension: 'js'
          },
          'ng2-bootstrap': {
            defaultExtension: 'js'
          }
        },
        map: {
          // place for ng2 modules mapping
          'ng2-bootstrap': 'node_modules/ng2-bootstrap'
        }
});

但是在这个解决方案之后我收到错误并且页面没有加载......

任何人都知道要遵循的步骤然后请告诉我。

4

1 回答 1

0

事实上,ng2-boostrap 提供了一个捆绑文件。只需将其添加到脚本元素中并删除 SystemJS 的相关配置即可:

<script src="node_modules/ng2-bootstrap/bundles/ng2-bootstrap.js"></script>

System.config({
    packages: {
      app: {
        format: 'register',
        defaultExtension: 'js'
      },
      'ng2-bootstrap': {
        defaultExtension: 'js'
      }
    },
    map: {
      // place for ng2 modules mapping
      'ng2-bootstrap': 'node_modules/ng2-bootstrap'
    }
});

这可以在使用 npm 安装 ng2-bootstrap 后完成。

于 2016-04-02T05:50:29.423 回答