【问题标题】:TypeScript errors while referencing Angular2 in Gulp在 Gulp 中引用 Angular2 时出现 TypeScript 错误
【发布时间】:2016-06-06 14:58:21
【问题描述】:

问题是

[11:16:06] TypeScript: 103 semantic errors
[11:16:06] TypeScript: emit succeeded (with errors)

我正在使用node v5.7.0npm 3.6.0

gulp -v:

[11:26:58] Requiring external module babel-register
[11:26:58] CLI version 3.9.1
[11:26:58] Local version 3.9.1

我完全是 babel 的初学者。

我在 ubuntu 15.10 下使用yo 1.6.0 生成了文件 generator-modern-web-dev 在新文件夹中。

错误是这样的

app/test/sanity_test.spec.ts(2,1): error TS2304: Cannot find name 'describe'.
app/test/sanity_test.spec.ts(3,2): error TS2304: Cannot find name 'it'.
app/test/sanity_test.spec.ts(4,3): error TS2304: Cannot find name 'expect'.
app/test/sanity_test.spec.ts(7,2): error TS2304: Cannot find name 'xit'.
app/test/sanity_test.spec.ts(8,3): error TS2304: Cannot find name 'expect'.
/home/danielduel/Pulpit/server/node_modules/angular2/platform/browser.d.ts(77,90): error TS2304: Cannot find name 'Promise'.

然后...更多错误。 (如果看到所有103错误非常关键,我可以发布它)

我成功地重新安装了sudo npm install npm_modules,但它并没有解决我正在处理的问题。

然后,来自

的任务“scripts-javascript-dist”
[11:16:09] 'scripts-javascript-dist' errored after 3.31 s
[11:16:09] Error: Error on fetch for npm:angular2@2.0.0-beta.7/bootstrap.js at file:///home/danielduel/Pulpit/server/jspm_packages/npm/angular2@2.0.0-beta.7/bootstrap.js

你能引导我解决这个问题吗?

我可以添加任务的源代码,但它们是在抽象的 ES2015 架构上完成的,它依赖于许多文件,但如果需要 - 给我信息。

我正在尝试并且看起来至少熟悉的 StackOverflow 线程:

  1. module not found angular, generates more errors
  2. this one looks good, but I do not understand at all
  3. this one, with config is not working as fix, generates more errors

我想,我遗漏了一些东西,但我不知道是什么。

【问题讨论】:

    标签: angularjs node.js typescript npm gulp


    【解决方案1】:

    您永远不需要在本地 sudo npm install

    根据您提供的错误,在我看来,项目似乎没有所有必需的类型定义,尤其是测试代码的这些。这可能是由某些无效的项目设置或包含的模块中的不正确引用引起的。

    请检查您的项目中是否有 tsd 或 typings,并为(我假设)jasmine 安装缺少的类型定义。

    https://github.com/typings/typings(新)

    http://definitelytyped.org/tsd/(已弃用)

    https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/jasmine/jasmine.d.ts

    很难说这是否是您的解决方案,但我希望这可以帮助您找到根本原因。

    【讨论】:

      猜你喜欢
      • 2017-02-10
      • 1970-01-01
      • 2016-02-16
      • 1970-01-01
      • 2016-06-08
      • 1970-01-01
      • 1970-01-01
      • 2017-03-12
      • 1970-01-01
      相关资源
      最近更新 更多