2017-10-17 52 views
0

我使用的IntelliJ IDEA 2017年2月4日製定角度(4個不是JS)應用程序。一切正常,運行良好,但IntelliJ標記所有@angular導入TypeScript文件與紅色的波浪狀。角的打字稿的IntelliJ進口標有抽搐

的錯誤消息是TS2307: Cannot find module '@nagular/abc'

存在Jetbrain的支持Typescript does not resolve modules through tsconfig.json's baseUrl

enter image description here

這是我tsconfig.json文件還發出打開。

請注意,tsconfig.json文件存儲不在項目的根,但./app/ui目錄 - 如果該事項。

{ 
    "compilerOptions": { 
    "alwaysStrict": true, 
    "noImplicitReturns": true, 
    "emitDecoratorMetadata": true, 
    "experimentalDecorators": true, 
    "module": "system", 
    "target": "es5", 
    "removeComments": true, 
    "suppressImplicitAnyIndexErrors": true, 
    "outDir": "generated", 
    "inlineSourceMap": true, 
    "importHelpers": true, 
    "baseUrl": ".", 
    "paths": { 
    "tslib": [ 
     "../../node_modules/tslib/tslib.d.ts" 
    ] 
    }, 
    "skipLibCheck": true, 
    "downlevelIteration": true 
    }, 
    "exclude": [ 
    "lib" 
    ] 
} 
+0

這可能是的IntelliJ期待在'tsconfig.json' –

+0

當你將鼠標懸停在進口的紅線它說什麼了定義的代碼風格? –

+0

我已經添加了錯誤信息 –

回答

1

你所有的角相關包的應該是 爲如:

node_modules/@angular/common/index.d.ts 
node_modules/@angular/compiler/index.d.ts 
node_modules/@angular/core/index.d.ts 
node_modules/@angular/http/index.d.ts 
node_modules/@angular/platform-browser/index.d.ts 
node_modules/@angular/platform-browser-dynamic/index.d.ts 
node_modules/@angular/router/index.d.ts 
node_modules/@angular/router-deprecated/index.d.ts 

然而,所有這些都應該在那裏,如果你已經從標準的快速入門https://angular.io/docs/ts/latest/quickstart.html使用的package.json文件並運行npm install

還要檢查你的IDE的tsconfig.json設置

File->settings->Languages & Frameworks -> TypeScript ->enable typescript compiler & Use tsconfig.json 
+0

我沒有看到任何index.d.ts在這些路徑 –

+0

我也沒有'啓用打字稿Compiler',因爲我不想的IntelliJ編譯.ts文件 –

0

當使用"module": "system"打字稿採用經典模塊的分辨率,這不能解決節點模塊,看細節在https://www.typescriptlang.org/docs/handbook/module-resolution.html

要使其工作,你需要切換到不同的模塊系統,如CommonJS的,或者有可能是另一種配置在使用"module": "system"時明確包含node_modules的分辨率。