2017-01-18 245 views
11

我被這個錯誤卡住了,有人可以幫我嗎? 我剛剛升級到Angular2.4.3無法讀取屬性'getLineAndCharacterOfPosition'undefined

$ ng serve                                            [19:46:01] 
** NG Live Development Server is running on http://localhost:4200. ** 
Hash: ed77e2590987da94e9d9                
Time: 4165ms 
chunk {0} scripts.bundle.js, scripts.bundle.map (scripts) 1.42 MB {4} [initial] [rendered] 
chunk {1} styles.bundle.js, styles.bundle.map (styles) 203 kB {4} [initial] [rendered] 
chunk {2} main.bundle.js, main.bundle.map (main) 576 bytes {3} [initial] [rendered] 
chunk {3} vendor.bundle.js, vendor.bundle.map (vendor) 234 kB [initial] [rendered] 
chunk {4} inline.bundle.js, inline.bundle.map (inline) 0 bytes [entry] [rendered] 

ERROR in Cannot read property 'getLineAndCharacterOfPosition' of undefined 

ERROR in ./src/main.ts 
Module build failed: Error: /Users/johntostring/Documents/web-workspace/ng2-qyweb/src/main.ts (3,40): Cannot find module '@angular/platform-browser-dynamic'.) 
/Users/johntostring/Documents/web-workspace/ng2-qyweb/src/main.ts (4,32): Cannot find module '@angular/core'.) 
    at _checkDiagnostics (/Users/johntostring/Documents/web-workspace/ng2-qyweb/node_modules/@ngtools/webpack/src/loader.js:145:15) 
    at /Users/johntostring/Documents/web-workspace/ng2-qyweb/node_modules/@ngtools/webpack/src/loader.js:172:17 
@ multi main 
webpack: bundle is now VALID. 

main.ts enter image description here

app.module.ts enter image description here

+0

我執行了'npm install'。所有依賴關係已成功下載 –

+1

請提供您的代碼。 – Mistalis

回答

0

太長了。我可能刪除了node_modules並再次嘗試npm install

+0

它也可能是錯誤的配置。我忘了 –

2

我觸發這個稍微有點隱蔽的錯誤,當我不小心忘記返回來自我的一個組件的getter函數的值。

get gene() { 
    // return this._gene; 
} 
16

這種情況發生時您修改tsconfig.app.jsontsconfig.json無效值。