2016-12-01 36 views
0

我正在使用Visual Studio Enterprise 2015 Update 3.我從Online模板創建了一個新項目「Angular2 Mvc5示例應用程序」。Angular2 Mvc5示例應用程序無法編譯

當我編譯它,我得到了很多類似的錯誤:

錯誤TS2307找不到模塊「@角/核心」。

錯誤TS2307找不到'@ angular/http'模塊。

錯誤TS2503找不到命名空間'模型'。

我能做些什麼才能編譯它而不會出現這些錯誤?

謝謝!

下面是我的tsconfig.json文件:

{ 
    "compileOnSave": true, 
    "compilerOptions": { 
    "target": "es5", 
    "module": "commonjs", 
    "moduleResolution": "node", 
    "sourceMap": true, 
    "emitDecoratorMetadata": true, 
    "experimentalDecorators": true, 
    "removeComments": false, 
    "noImplicitAny": false 
    }, 
    "exclude": [ 
    "node_modules", 
    "typings/main", 
    "typings/main.d.ts", 
    "Scripts/TypeLite.Net4.d.ts" 
    ] 
} 
+0

你做了npm安裝嗎? – 12seconds

+0

你使用的是什麼版本的nodejs? – user65439

+0

你是否參考:npm install Angular2? –

回答

0

我創建你提到的模板中的項目。使用「右鍵單擊package.json和Restore Packages」沒有任何運氣,輸出中顯示的包沒有找到404。

因此,我通過命令行做了「npm install」,而且我能夠編譯得很好。

確保您的目錄中存在「node_modules」。

另一件需要注意的是package.json上的包已經過時了。

+0

我通過命令行做了「npm install」,現在一切都很好。謝謝! –