2016-10-13 6 views
2

グラフ用にng2-nvd3モジュールを使用しています。以下は、私はエラーの下に取得していますコードionic2モジュール 'AppModule'によって予期しない値 'nvD3'が発生しました

角度2、イオン2

import {nvD3} from "ng2-nvd3/build/lib/ng2-nvd3"; 
@NgModule({ 
    declarations: [ 
     nvD3, 
... 
}) 

です。誰もが、私は同じエラーを持っていた私は、エラー

の下
[15:51:10] lint finished in 1.04 s 
[15:51:11] ngc: Error: Unexpected value 'nvD3' declared by the module 'AppModule' 
    at /Users/…/node_modules/@angular/compiler/bundles/compiler.umd.js:14044:33 
    at Array.forEach (native) 
    at CompileMetadataResolver.getNgModuleMetadata (/Users/…/node_modules/@angular/compiler/bundles/compiler.umd.js:14031:51) 
    at /Users/..//node_modules/@angular/compiler/bundles/compiler.umd.js:12801:47 
    at Array.forEach (native) 
    at analyzeModules (/Users/…/node_modules/@angular/compiler/bundles/compiler.umd.js:12800:17) 
    at OfflineCompiler.analyzeModules (/Users/…/node_modules/@angular/compiler/bundles/compiler.umd.js:12826:18) 
    at CodeGenerator.codegen (/Users/…/node_modules/@angular/compiler-cli/src/codegen.js:105:47) 
    at codegen (/Users/…/node_modules/@angular/compiler-cli/src/main.js:7:81) 
    at Object.main (/Users/..//node_modules/@angular/tsc-wrapped/src/main.js:30:16) 
+0

同じ問題が発生しました。これを修正できますか?ありがとう – Martin

答えて

0

を解決するのに役立つことができ、ここで私は私のコードでそれを固定する方法である:

... 
import { Key } from "../../utils/key"; 

declare var setLanguage; //Makes sure this forcing of type (a hack) is here 

@Component({ 
    selector: "page-home", 
    templateUrl: "home.html", 
    providers: [Storage] 
}) 

//declare var setLanguage; //NOT HERE 

export class HomePage { 
... 
+0

これはどのようにOPの問題を解決しますか? – Martin

+1

問題は、別のソースファイルのコードが原因である可能性があります。私のコードの上記のバグのために、彼と同じエラーが発生しました。それはおそらく彼の問題ではないが、他人を助けるかもしれない。 – tezcan

0

間違っ

import {nvD3} from "ng2-nvd3/build/lib/ng2-nvd3"; 

import { nvD3 } from 'ng2-nvd3'; 
関連する問題