javascript - Angular2 boot.ts 意外错误

标签 javascript angular directory

我目前正在尝试 Angular 2 的不同文件夹结构,当尝试启动本地服务器时,出现以下错误:

Uncaught SyntaxError: Unexpected token <
    Evaluating http://localhost:3000/prod/app/TypeScript/boot
    Error loading http://localhost:3000/prod/app/TypeScript/boot

文件夹结构:

index.html

开发

---应用程序

------TypeScript

------------app.component.ts

------------boot.ts

最佳答案

你可以尝试这样配置 SystemJS:

<script>
  System.config({
    map: {
      app: 'prod/app'
    },
    packages: {
      app: {
        format: 'register',
        defaultExtension: 'js'
      }
    }
  });
  System.import('app/TypeScript/boot')
        .then(null, console.error.bind(console));

在您的情况下,defaultExtension 属性不适用,因此与您的模块对应的 URL 不正确:http://localhost:3000/prod/app/TypeScript/boot 而不是 http://localhost:3000/prod/app/TypeScript/boot.js

此外,这可能是一个拼写错误,但您有一个 dev 文件夹,而不是 prod 文件夹...

关于javascript - Angular2 boot.ts 意外错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36046764/

相关文章:

javascript - 使用json在html中构建树结构

javascript - 使用 jQuery 更改 &lt;input&gt; 标记时的触发功能(复选框/文本框)

Angular url 不区分大小写

python - 哪些脚本会进入 Python 包的 bin 文件夹?

c# - 替换C#中所有目录和文件的名称

javascript - Codeacademy 类(class) JavaScript 的问题

javascript - 无法捕获从 Angular 4 中的子组件发出的事件

angular - 如何使用 ngStyle 添加背景图片?

javascript - 获取 Cordova 目录中的文件列表

javascript - 通过 JS 设置时 Bootstrap 输入验证消息不显示 php