2016-06-12 3 views
1

사용시에는 다음과 같은 코드 ...'module'이름을 찾을 수 없습니다. commonjs

@Component({ 
    module: module.id, 
    selector: 'hero', 
    templateUrl:'hero.component.html', 
    styleUrls: ['hero.component.css'], 
    directives: [HeroDetailComponent, MD_CARD_DIRECTIVES, MD_BUTTON_DIRECTIVES, MD_LIST_DIRECTIVES, MD_ICON_DIRECTIVES, MdToolbar, MD_INPUT_DIRECTIVES], 
    providers: [HeroService], 
    viewProviders: [MdIconRegistry] 
}) 
export class HeroComponent implements OnInit{ 
... 
} 

//tsconfig.js 
{ 
    "compilerOptions": { 
    "target": "es5", 
    "module": "commonjs", 
    "rootDir": "src/ng2", 
    "moduleResolution": "node", 
    "sourceMap": false, 
    "inlineSources": true, 
    "inlineSourceMap": true, 
    "emitDecoratorMetadata": true, 
    "experimentalDecorators": true, 
    "removeComments": false, 
    "outDir": "public/ng2", 
    "noImplicitAny": false 
    }, 
    "exclude": [ 
    "node_modules", 
    "typings/main", 
    "typings/main.d.ts" 
    ] 
} 

하지만 실행할 때 내가 좀 ..

SRC/NG2/구성 요소/영웅/hero.component.ts (15 , 13) : 오류 TS2304 : '모듈'이름을 찾을 수 없습니다.

UPDATE

나는, 알려진 속성을 지정할 수 있습니다 ... this question

"globalDependencies": { 
    "node": "registry:dt/node#6.0.0+20160608110640" 
} 

하지만 여전히 볼 수에 따라 단계를 수행하는

객체 리터럴을 시도 및 '모듈'유형에 존재하지 않습니다

(210)

업데이트 2 부트 스트랩 파일을 업데이트 한 후 나는 아직도

SRC/NG2/구성 요소/영웅/hero.component.ts를 참조

import {bootstrap}  from '@angular/platform-browser-dynamic'; 
import {HeroComponent} from './components/hero/hero.component'; 
import { HTTP_PROVIDERS } from '@angular/http'; 
declare var module:any; 
bootstrap(HeroComponent, [ HTTP_PROVIDERS ]); 

... 같이하는 (15,5) : 오류 TS2345 : '{module : string; 선택자 : 문자열; 템플릿 : 문자열; styleUrls : 문자열 []; 지시어 : (typeof He ... '는'{selector ?: string; inputs ?: string []; type? : string []; properties ?: 문자열 []; events ?: strin ..의 매개 변수에 할당 할 수 없습니다. ' 객체 리터럴은 알려진 속성 만 지정할 수 있으며'module '은 유형'{selector ?: string; inputs ?: string [];은 ?: 문자열 []; 속성 ?: 문자열 []; ? :. strin ... '여기

project

답변

1

업데이트입니다

좋아, 이제 타이프 정의 파일에이 줄을 추가하고 F에 대한 참조를 추가 할 수 부트 스트랩 파일 내의 ile. 당신의 각도 시작 스크립트의 상단에 추가 : 그런 다음 참조 경로에서 파일을 생성 할 필요가

///<reference path="./path/to/custom.typings.d.ts"/>

. 당신의 각도 시작 스크립트 (각도의 bootstrap 함수를 호출하는 스크립트)에서 declare var module:any;

원래 대답

부트 스트랩 위 근처에 다음 줄을 추가합니다 : 그 파일에서 줄을 추가

declare var module:any;

필자는 필자가 제안한대로 종속성을 구성했기 때문에이 오류가 발생하는 이유를 모르겠습니다.문제가 없다는 것을 알고 있기 때문에 컴파일러가 불평을 멈추게 할 라인을 추가했습니다.

+0

시도했지만 여전히 문제가있는 것 같습니다. 어떤 아이디어? 업데이트 – Jackie

+0

수정 된 답변 체크 아웃을 참조하십시오. 어쩌면 선은 타이프 스크립트 정의 파일에 있어야 할 것입니다. – BeetleJuice

+0

나는 아직도 그것을 내 transpiler로 systemJS를 사용할 수 있습니까? – Jackie

관련 문제