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

键入角找不到名称错误

姜华翰
2023-03-14

当我试图运行angular2-express应用程序“NPM运行开发”时,我得到了“找不到名称‘promise’错误”

node_modules/@angular/common/src/directives/ng_class.d.ts(81,34):error TS2304: Cannot find name 'Set'.
[1] node_modules/@angular/common/src/facade/lang.d.ts(11,17): error TS2304: Cannot find name 'Map'.
[1] node_modules/@angular/common/src/facade/lang.d.ts(12,17): error TS2304: Cannot find name 'Set'.
[1] node_modules/@angular/common/src/facade/lang.d.ts(67,59): error TS2304: Cannot find name 'Map'.
[1] node_modules/@angular/common/src/pipes/async_pipe.d.ts(41,38): error TS2304: Cannot find name 'Promise'.
[1] node_modules/@angular/core/src/application_init.d.ts(16,18): error TS2304: Cannot find name 'Promise'.
[1] node_modules/@angular/core/src/application_ref.d.ts(99,88): error TS2304: Cannot find name 'Promise'.
[1] node_modules/@angular/core/src/application_ref.d.ts(134,67): error TS2304: Cannot find name 'Promise'.
[1] node_modules/@angular/core/src/application_ref.d.ts(150,109): error TS2304: Cannot find name 'Promise'.
[1] node_modules/@angular/core/src/application_ref.d.ts(202,67): error TS2304: Cannot find name 'Promise'.
[1] node_modules/@angular/core/src/application_ref.d.ts(204,109): error TS2304: Cannot find name 'Promise'.
[1] node_modules/@angular/core/src/application_ref.d.ts(236,42): error TS2304: Cannot find name 'Promise'.
[1] node_modules/@angular/core/src/application_ref.d.ts(331,33): error TS2304: Cannot find name 'Promise'.
[1] node_modules/@angular/core/src/facade/collection.d.ts(1,25): error TS2304: Cannot find name 'MapConstructor'.
[1] node_modules/@angular/core/src/facade/collection.d.ts(2,25): error TS2304: Cannot find name 'SetConstructor'.
[1] node_modules/@angular/core/src/facade/collection.d.ts(4,27): error TS2304: Cannot find name 'Map'.
[1] node_modules/@angular/core/src/facade/collection.d.ts(4,39): error TS2304: Cannot find name 'Map'.
[1] node_modules/@angular/core/src/facade/collection.d.ts(7,9): error TS2304: Cannot find name 'Map'.
[1] node_modules/@angular/core/src/facade/collection.d.ts(8,30): error TS2304: Cannot find name 'Map'.
[1] node_modules/@angular/core/src/facade/collection.d.ts(11,43): error TS2304: Cannot find name 'Map'.
[1] node_modules/@angular/core/src/facade/collection.d.ts(12,27): error TS2304: Cannot find name 'Map'.
[1] node_modules/@angular/core/src/facade/collection.d.ts(14,23): error TS2304: Cannot find name 'Map'.
[1] node_modules/@angular/core/src/facade/collection.d.ts(15,25): error TS2304: Cannot find name 'Map'.
[1] node_modules/@angular/core/src/facade/collection.d.ts(100,41): error TS2304: Cannot find name 'Set'.
[1] node_modules/@angular/core/src/facade/collection.d.ts(101,22): error TS2304: Cannot find name 'Set'.
[1] node_modules/@angular/core/src/facade/collection.d.ts(102,25): error TS2304: Cannot find name 'Set'.
[1] node_modules/@angular/core/src/facade/lang.d.ts(11,17): error TS2304: Cannot find name 'Map'.
[1] node_modules/@angular/core/src/facade/lang.d.ts(12,17): error TS2304: Cannot find name 'Set'.
[1] node_modules/@angular/core/src/facade/lang.d.ts(67,59): error TS2304: Cannot find name 'Map'.
[1] node_modules/@angular/core/src/linker/compiler.d.ts(47,76): error TS2304: Cannot find name 'Promise'.
[1] node_modules/@angular/core/src/linker/compiler.d.ts(62,57): error TS2304: Cannot find name 'Promise'.

.....
.....

以下是几个文件的内容

package.json

{
  "name": "angular2-express-starter",
  "version": "1.0.0",
  "description": "Starter application of Angular2 on Express",
  "main": "gulpfile.js",
  "private": true,
  "scripts": {
    "develop": "concurrently \"tsc -w -p ./server\" \"tsc -w -p ./client\" \"nodemon ./server/bin/www\" ",
    "twc:client:w": "tsc -w -p ./client",
    "twc:server:w": "tsc -w -p ./server",
    "typings": "typings install",
    "bundle": "node tools/builder.js",
    "bundle:prod": "node tools/builder.js --prod",
    "postinstall": "typings install && tsc -p ./server"
  },
  "engines": {
    "node": ">= 5.4.1 < 6"
  },
  "author": "Vlado Tešanović",
  "license": "MIT",
  "dependencies": {
    "bcrypt": "^0.8.7",
    "body-parser": "~1.13.2",
    "cookie-parser": "~1.3.5",
    "express": "^4.13.4",
    "express-jwt": "^3.3.0",
    "jsonwebtoken": "^5.7.0",
    "jwt-simple": "*",
    "morgan": "*",
    "mysql": "^2.11.1",
    "serve-favicon": "~2.3.0",
    "typescript": "^1.8.10",
    "typings": "^1.3.2"
  },
  "devDependencies": {
    "@angular/common": "2.0.0-rc.5",
    "@angular/compiler": "2.0.0-rc.5",
    "@angular/core": "2.0.0-rc.5",
    "@angular/forms": "0.3.0",
    "@angular/http": "2.0.0-rc.5",
    "@angular/platform-browser": "2.0.0-rc.5",
    "@angular/platform-browser-dynamic": "2.0.0-rc.5",
    "@angular/router": "^3.0.0-rc.1",
    "@angular/router-deprecated": "^2.0.0-rc.2",
    "@angular/upgrade": "2.0.0-rc.5",
    "angular2-in-memory-web-api": "0.0.15",
    "angular2-jwt": "^0.1.18",
    "concurrently": "^2.2.0",
    "core-js": "^2.4.1",
    "ng-semantic": "^1.0.33",
    "nodemon": "^1.9.1",
    "reflect-metadata": "^0.1.3",
    "retyped-bcrypt-tsd-ambient": "0.0.0-0",
    "rxjs": "5.0.0-beta.6",
    "systemjs": "0.19.27",
    "systemjs-builder": "^0.15.17",
    "yargs": "^4.8.1",
    "zone.js": "^0.6.12"
  }
}

json

{
    "globalDependencies": {
        "body-parser": "registry:dt/body-parser#0.0.0+20160619023215",
        "es6-collections": "registry:dt/es6-collections#0.5.1+20160316155526",
        "es6-promise": "registry:dt/es6-promise#0.0.0+20160614011821",
        "express": "registry:dt/express#4.0.0+20160708185218",
        "express-serve-static-core": "registry:dt/express-serve-static-core#4.0.0+20160715232503",
        "jasmine": "registry:dt/jasmine#2.2.0+20160621224255",
        "jquery": "registry:dt/jquery#1.10.0+20160704162008",
        "mime": "registry:dt/mime#0.0.0+20160316155526",
        "node": "registry:dt/node#6.0.0+20160720070758",
        "serve-favicon": "registry:dt/serve-favicon#0.0.0+20160316155526",
        "serve-static": "registry:dt/serve-static#0.0.0+20160606155157"
      },
      "dependencies": {
        "jsonwebtoken": "registry:npm/jsonwebtoken#5.5.4+20160208220328"
      }
    }
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule }              from './components/app.module';

platformBrowserDynamic().bootstrapModule(AppModule);
import { Component } from "@angular/core";
import { ROUTER_DIRECTIVES } from '@angular/router';
import { Header } from './header/header'
import { Footer } from './footer/footer'
import { UserService } from "../services/user.service";

@Component({
    directives: [ ROUTER_DIRECTIVES, Header, Footer ],
    selector: "app",
    templateUrl: "client/components/app.html",
    styles: [
        './rajd-theme.css'
    ]
})
export class App {
    constructor(private userService: UserService) {

    }
}
import { NgModule }       from '@angular/core';
import { BrowserModule  } from '@angular/platform-browser';
import { FormsModule  } from '@angular/forms';
import { RouterModule  } from '@angular/router';

import { App }   from './app.ts';

@NgModule({
    declarations: [App],
    imports:      [
        BrowserModule,
        FormsModule,
        RouterModule
    ],
    bootstrap:    [App],
})
export class AppModule {}

共有1个答案

梁修贤
2023-03-14

我也遇到了同样的问题,但是我通过更改tsconfig.json中的“target”:“es2015”来解决这个问题。我不能告诉你为什么这为我解决了这个问题,但它奏效了。

 类似资料:
  • 我是angular 2和typescript的新手,正在尝试为我的弹出窗口调用RocketLaunch函数。 如果我在弹出窗口外声明它不调用,但如果我在弹出窗口内移动它抛出此错误: 错误TS2304:找不到名称“$event” 提供以下相关代码和错误:

  • 问题内容: 我开始使用TypeScript编写AngularJS应用。我有这个简单的模块命令: 当我跑步时,我得到了: 我是否需要包括一些内容以使他们理解? 问候, 问题答案: 您可以通过告诉编译器“您对角度的全部了解”来简单地告诉编译器不再担心: 为了获得所有好的工具和类型检查,您需要提取Angular类型定义,以便编译器知道可用的东西。 如果您对自己喜欢的IDE使用Visual Studio或

  • 基本上,当我调用google analytics api获取核心报告数据时,我会收到下面的错误。它在我的本地主机服务器上工作,但当我试图部署应用程序时,它失败了。请建议如何在Angular2+中导入“GAPI”变量。多谢! 我在angular应用程序中就是这样称呼它的。 gapi.auth.authorize(authData,(res:any)=>{}) tsconfig.json

  • 我试图启动并运行我的第一个TypeScript和DefinitelyTyped Node.js应用程序,但遇到了一些错误。 当我尝试传输一个简单的TypeScript node.js页面时,我收到错误“TS2304:无法找到名称'require'”。我已经阅读了其他几次发生在Stack ;溢出上的此错误,我认为我没有类似的问题。我正在shell提示符下运行命令: 该文件的内容为: 在行上抛出错误。

  • 问题内容: 我正在尝试启动并运行我的第一个TypeScript和DefinitelyTyped Node.js应用程序,并且遇到一些错误。 尝试转换简单的TypeScript Node.js页面时,出现错误“ TS2304:找不到名称’require’”。我已经阅读了Stack Overflow上多次出现此错误的信息,但我认为我没有类似的问题。我在shell提示符下运行命令: 该文件的内容是: 错