2016-08-20 242 views
3

我正在故宮運行發展‘分型角找不到名稱錯誤

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'. 

..... 
..... 

這些都是幾個文件

內容「試圖運行angular2-Express的應用程序時無法找到名爲‘無極’的錯誤’

的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" 
    } 
} 

typings.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" 
     } 
    } 

main.ts

import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 
import { AppModule }    from './components/app.module'; 

platformBrowserDynamic().bootstrapModule(AppModule); 

app.ts

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) { 

    } 
} 

app.module.ts

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 {} 

請注意,我正在使用角rc5和NgModules。

+0

我想[這個答案](http://stackoverflow.com/a/35660772/2435473)應該會幫你 –

+0

已經試過這個,didn不工作@PankajParkar –

回答

2

我有這個問題,但我設法通過更改"target": "es2015"tsconfig.json解決它。我無法告訴你爲什麼這樣解決了我的問題,但它工作。

+1

不,它沒有工作 –

+0

爲我工作。謝謝 – Frohlich

1

如果您遇到無法找到名稱錯誤,大多數情況下您已經更改了基本設置中的某些文件,或者可能是您沒有成功完成節點包安裝。 Angular2不再使用打字包。

解決方案:

克隆以下庫https://github.com/angular/quickstart 運行NPM安裝在項目目錄中,並確保它成功地完成現在 複製和配置你的應用程序的項目文件夾到克隆的新文件夾現在,這將很好地工作。

0

您可以嘗試將"lib": ["es6"]添加到您的tsconfig.json配置文件中。如果你使用瀏覽器符號如窗口等,你也可以嘗試"lib": ["es6", "dom"]

相關問題