当前位置: 首页 > 知识库问答 >
问题:

Angular2构建错误-找不到类型

窦英武
2023-03-14
> tsc && concurrently "npm run tscw" "npm run lite"

node_modules/@angular/common/src/directives/ng_class.d.ts(72,35): error TS2304: Cannot find name 'Set'.
node_modules/@angular/common/src/facade/async.d.ts(27,33): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/common/src/facade/async.d.ts(28,45): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/common/src/facade/lang.d.ts(4,17): error TS2304: Cannot find name 'Map'.
node_modules/@angular/common/src/facade/lang.d.ts(5,17): error TS2304: Cannot find name 'Set'.
node_modules/@angular/common/src/facade/lang.d.ts(70,59): error TS2304: Cannot find name 'Map'.
node_modules/@angular/common/src/facade/promise.d.ts(2,14): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/common/src/facade/promise.d.ts(8,32): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/common/src/facade/promise.d.ts(9,38): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/common/src/facade/promise.d.ts(10,35): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/common/src/facade/promise.d.ts(10,93): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/common/src/facade/promise.d.ts(11,34): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/common/src/facade/promise.d.ts(11,50): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/common/src/facade/promise.d.ts(12,32): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/common/src/facade/promise.d.ts(12,149): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/common/src/facade/promise.d.ts(13,43): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/common/src/forms/directives/select_control_value_accessor.d.ts(18,17): error TS2304: Cannot find name 'Map'.
node_modules/@angular/common/src/pipes/async_pipe.d.ts(29,29): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/common/src/pipes/async_pipe.d.ts(35,38): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/common/src/pipes/async_pipe.d.ts(37,39): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/common/src/pipes/async_pipe.d.ts(39,44): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/application_ref.d.ts(39,88): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/application_ref.d.ts(99,42): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/application_ref.d.ts(174,33): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/change_detection/differs/default_keyvalue_differ.d.ts(24,15): error TS2304: Cannot find name 'Map'.
node_modules/@angular/core/src/change_detection/differs/default_keyvalue_differ.d.ts(26,16): error TS2304: Cannot find name 'Map'.
node_modules/@angular/core/src/di/reflective_provider.d.ts(105,123): error TS2304: Cannot find name 'Map'.
node_modules/@angular/core/src/di/reflective_provider.d.ts(105,165): error TS2304: Cannot find name 'Map'.
node_modules/@angular/core/src/facade/async.d.ts(27,33): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/facade/async.d.ts(28,45): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/facade/collection.d.ts(1,25): error TS2304: Cannot find name 'MapConstructor'.
node_modules/@angular/core/src/facade/collection.d.ts(2,25): error TS2304: Cannot find name 'SetConstructor'.
node_modules/@angular/core/src/facade/collection.d.ts(4,27): error TS2304: Cannot find name 'Map'.
node_modules/@angular/core/src/facade/collection.d.ts(4,39): error TS2304: Cannot find name 'Map'.
node_modules/@angular/core/src/facade/collection.d.ts(7,9): error TS2304: Cannot find name 'Map'.
node_modules/@angular/core/src/facade/collection.d.ts(8,30): error TS2304: Cannot find name 'Map'.
node_modules/@angular/core/src/facade/collection.d.ts(11,43): error TS2304: Cannot find name 'Map'.
node_modules/@angular/core/src/facade/collection.d.ts(12,27): error TS2304: Cannot find name 'Map'.
node_modules/@angular/core/src/facade/collection.d.ts(14,23): error TS2304: Cannot find name 'Map'.
node_modules/@angular/core/src/facade/collection.d.ts(15,25): error TS2304: Cannot find name 'Map'.
node_modules/@angular/core/src/facade/collection.d.ts(100,41): error TS2304: Cannot find name 'Set'.
node_modules/@angular/core/src/facade/collection.d.ts(101,22): error TS2304: Cannot find name 'Set'.
node_modules/@angular/core/src/facade/collection.d.ts(102,25): error TS2304: Cannot find name 'Set'.
node_modules/@angular/core/src/facade/lang.d.ts(4,17): error TS2304: Cannot find name 'Map'.
node_modules/@angular/core/src/facade/lang.d.ts(5,17): error TS2304: Cannot find name 'Set'.
node_modules/@angular/core/src/facade/lang.d.ts(70,59): error TS2304: Cannot find name 'Map'.
node_modules/@angular/core/src/facade/promise.d.ts(2,14): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/facade/promise.d.ts(8,32): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/facade/promise.d.ts(9,38): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/facade/promise.d.ts(10,35): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/facade/promise.d.ts(10,93): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/facade/promise.d.ts(11,34): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/facade/promise.d.ts(11,50): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/facade/promise.d.ts(12,32): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/facade/promise.d.ts(12,149): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/facade/promise.d.ts(13,43): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/linker/component_resolver.d.ts(8,53): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/linker/component_resolver.d.ts(12,44): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/linker/dynamic_component_loader.d.ts(62,148): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/linker/dynamic_component_loader.d.ts(103,144): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/linker/dynamic_component_loader.d.ts(108,139): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/linker/dynamic_component_loader.d.ts(109,135): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/reflection/reflector.d.ts(28,22): error TS2304: Cannot find name 'Map'.
node_modules/@angular/core/src/reflection/reflector.d.ts(30,15): error TS2304: Cannot find name 'Map'.
node_modules/@angular/core/src/reflection/reflector.d.ts(32,15): error TS2304: Cannot find name 'Map'.
node_modules/@angular/core/src/reflection/reflector.d.ts(34,15): error TS2304: Cannot find name 'Map'.
node_modules/@angular/core/src/reflection/reflector.d.ts(36,16): error TS2304: Cannot find name 'Set'.
node_modules/@angular/core/src/testability/testability.d.ts(40,20): error TS2304: Cannot find name 'Map'.
node_modules/@angular/http/src/headers.d.ts(29,18): error TS2304: Cannot find name 'Map'.
node_modules/@angular/http/src/headers.d.ts(45,59): error TS2304: Cannot find name 'Map'.
node_modules/@angular/http/src/url_search_params.d.ts(11,16): error TS2304: Cannot find name 'Map'.
node_modules/@angular/platform-browser-dynamic/platform_browser_dynamic.d.ts(75,90): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/router-deprecated/src/directives/router_outlet.d.ts(27,54): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/router-deprecated/src/directives/router_outlet.d.ts(33,51): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/router-deprecated/src/directives/router_outlet.d.ts(38,56): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/router-deprecated/src/directives/router_outlet.d.ts(47,65): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/router-deprecated/src/directives/router_outlet.d.ts(58,60): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/router-deprecated/src/facade/async.d.ts(27,33): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/router-deprecated/src/facade/async.d.ts(28,45): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/router-deprecated/src/facade/lang.d.ts(4,17): error TS2304: Cannot find name 'Map'.
node_modules/@angular/router-deprecated/src/facade/lang.d.ts(5,17): error TS2304: Cannot find name 'Set'.
node_modules/@angular/router-deprecated/src/facade/lang.d.ts(70,59): error TS2304: Cannot find name 'Map'.
node_modules/@angular/router-deprecated/src/facade/promise.d.ts(2,14): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/router-deprecated/src/facade/promise.d.ts(8,32): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/router-deprecated/src/facade/promise.d.ts(9,38): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/router-deprecated/src/facade/promise.d.ts(10,35): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/router-deprecated/src/facade/promise.d.ts(10,93): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/router-deprecated/src/facade/promise.d.ts(11,34): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/router-deprecated/src/facade/promise.d.ts(11,50): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/router-deprecated/src/facade/promise.d.ts(12,32): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/router-deprecated/src/facade/promise.d.ts(12,149): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/router-deprecated/src/facade/promise.d.ts(13,43): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/router-deprecated/src/instruction.d.ts(125,34): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/router-deprecated/src/instruction.d.ts(161,25): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/router-deprecated/src/instruction.d.ts(179,34): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/router-deprecated/src/instruction.d.ts(182,25): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/router-deprecated/src/interfaces.d.ts(21,107): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/router-deprecated/src/interfaces.d.ts(39,104): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/router-deprecated/src/interfaces.d.ts(57,109): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/router-deprecated/src/interfaces.d.ts(80,109): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/router-deprecated/src/interfaces.d.ts(102,114): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/router-deprecated/src/lifecycle/lifecycle_annotations.d.ts(29,100): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/router-deprecated/src/route_config/route_config_impl.d.ts(105,19): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/router-deprecated/src/route_definition.d.ts(20,20): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/router-deprecated/src/route_definition.d.ts(35,20): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/router-deprecated/src/route_registry.d.ts(52,66): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/router-deprecated/src/router.d.ts(56,50): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/router-deprecated/src/router.d.ts(68,46): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/router-deprecated/src/router.d.ts(86,45): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/router-deprecated/src/router.d.ts(99,34): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/router-deprecated/src/router.d.ts(107,64): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/router-deprecated/src/router.d.ts(112,85): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/router-deprecated/src/router.d.ts(114,51): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/router-deprecated/src/router.d.ts(116,72): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/router-deprecated/src/router.d.ts(122,48): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/router-deprecated/src/router.d.ts(128,70): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/router-deprecated/src/router.d.ts(140,43): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/router-deprecated/src/router.d.ts(144,29): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/router-deprecated/src/router.d.ts(150,19): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/router-deprecated/src/router.d.ts(162,70): error TS2304: Cannot find name 'Promise'.
node_modules/rxjs/Observable.d.ts(10,66): error TS2304: Cannot find name 'Promise'.
node_modules/rxjs/Observable.d.ts(66,60): error TS2304: Cannot find name 'Promise'.
node_modules/rxjs/Observable.d.ts(66,70): error TS2304: Cannot find name 'Promise'.
node_modules/rxjs/operator/toPromise.d.ts(7,59): error TS2304: Cannot find name 'Promise'.
node_modules/rxjs/operator/toPromise.d.ts(7,69): error TS2304: Cannot find name 'Promise'.
node_modules/rxjs/operator/toPromise.d.ts(9,9): error TS2304: Cannot find name 'Promise'.
node_modules/rxjs/operator/toPromise.d.ts(10,26): error TS2304: Cannot find name 'Promise'.
node_modules/rxjs/operator/toPromise.d.ts(10,36): error TS2304: Cannot find name 'Promise'.
src/classes/animal.ts(42,18): error TS2339: Property 'startsWith' does not exist on type 'string'.

有什么想法吗?(角2)

共有1个答案

鞠源
2023-03-14

如果使用--target=es5,则需要在应用程序的某个地方(例如,在调用bootstrap的.ts文件顶部)添加一行:

<reference path="node_modules/angular2/typings/browser.d.ts"/>

看这篇帖子:角2打字稿找不到名字

我个人切换到ES6,它的工作完美到目前为止。我还建议为Angular2做5min的快速入门和教程系列,因为您可以将其用作进一步项目的稳定框架:https://angular.io/guide/QuickStart

 类似资料:
  • 问题内容: 我有一个由Eclipse生成的.jar,我无法在其他计算机(与Windows XP)上运行。出现“找不到主类。程序将退出”消息。那台计算机可以在Netbeans生成的另一个.jar上正常运行,所以我想JRE并不是问题。我更新了JRE,但没有改变。问题是什么? 更新:我忘了提,我做了一个可运行的jar文件。在另外两台计算机上,它可以正常工作(win 7和XP),但在特定计算机上则不能。

  • 问题内容: 所有, 我的类路径已设置为以下文件夹: 我所有的Java文件和类文件都在中列出的文件夹下。 但是在运行in 文件夹时出现以下错误: 谁能帮我理解这里的原因? 问题答案: 您在包装内。您应该坐在包根目录中。上一个文件夹。 然后使用重新执行它。 就是说,您不应该使用环境变量。您的当前也是无效的。未加引号的路径名中有空格。另外,该文件夹不应放在类路径中。只需使用like这样的参数(坐在包根文

  • 似乎不知道为什么这个简单的程序在我的电脑上停止工作。我编译的程序直到视窗更新都很好,但是当我试图编译一个新程序时,我得到了以下信息。我附上了程序的图片和命令提示符错误信息。我检查了CLASSPATH,它看起来很好。 程序-HelloWorldApp。JAVA 执行javac HelloWorldApp。爪哇——一切都很好 执行java HelloWorldApp- 错误:在HelloWorldAp

  • 问题内容: 我正在使用angular2和gulp开发一个节点应用程序。我编写了一个组件文件login.ts,如下所示: 我的bootstrap.ts文件是: 但是当我编译这些文件时,出现以下错误: 这是我的tsconfig.json: 我已经使用以下命令安装了angular2的类型: 请帮助纠正错误。 问题答案: @simon错误说的是输入错误。但是对于其他进口商品,我已经发布了此答案,可能对其他

  • 我试图在我的react本机应用程序上集成Firebase Crashlytics,但在构建应用程序时出错。 错误:配置根项目“MyApp”时出现问题 无法解析配置“:classpath”的所有项目。找不到io。织物工具:渐变:1.26.1。在以下位置搜索:https://dl.google.com/dl/android/maven2/io/fabric/tools/gradle/1.26.1/gr

  • 我尝试在模拟器中构建我的应用程序后出现了这样的错误 /Users/joel/.gradle/caches/transforms-3/06231cc1265260b25a06bafce7a4176f/transformed/core-1.7.0-alpha02/res/values/values。xml:105:5-114:25:AAPT:error:resource-android:attr/lS