2017-07-28 54 views
0

我想創建一個角2應用的Visual Studio 2017年採用了棱角分明2

下面是打字稿代碼

import { Component } from 'angular2/core'; 
@Component({ 
    selector: 'my-app', 
    template: ' <h1> My First SharePoint Add In using Angular2... !!! < /h1>' 
}) 
export class AppComponent { } 

它拋出下面的錯誤

拋出編譯錯誤打字稿文件

找不到模塊angular2/core

修飾器的實驗支持是一個功能,在未來的版本

O更改對於第二個錯誤,我也於tsconfig.json

我還安裝了TypeScript SDK for Visual Studio 2017並重新啓動Visual Studio中添加

"experimentalDecorators": true, 

,但沒有運氣

我也試過npm install -g [email protected]

下面是m Ÿ的package.json

{ 
    "name": "imageslideshow", 
    "version": "1.0.0", 
    "description": "slide show for image libraries", 
    "main": "index.js", 
    "dependencies": { 
    "@angular/core": "^4.3.2", 
    "angular2": "^2.0.0-beta.17", 
    "es6-promise": "^4.1.1", 
    "es6-shim": "^0.35.3", 
    "reflect-metadata": "^0.1.2", 
    "rxjs": "^5.0.0-beta.6", 
    "systemjs": "^0.20.17", 
    "zone.js": "^0.8.16" 
    }, 
    "devDependencies": {}, 
    "scripts": { 
    "test": "echo \"Error: no test specified\" && exit 1" 
    }, 
    "author": "vignesh", 
    "license": "ISC" 
} 

,當我嘗試安裝NPM我得到的消息如下 enter image description here

+1

嘗試運行 '故宮安裝' –

+0

是的,我試過'NPM安裝-g打字稿@ latest' –

+1

不NPM安裝-g,但只是npm安裝在你的解決方案或其子目錄中,你有你的軟件包 –

回答

1
  1. 確保您已對項目運行的npm install和 依賴是在node_modules文件夾中。

  2. 在您的package.json文件中,您與第2版和第4版的Angular 有相關性。決定要使用哪一個。

如果你想使用角版本4的進口應該是:

import { Component } from '@angular/core'; 
+0

嘗試了npm install,但看起來像是有一些問題 –