0

I am trying to create an angular 2 app

Below is the typescript code

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

It is throwing the below errors

cannot find module angular2/core

Experimental support for decorators is a feature that is subject to change in a future release

For the second error I have also added

"experimentalDecorators": true,

in the tsconfig.json

I have also installed TypeScript SDK for Visual Studio 2017 and restarted Visual studio, but no luck

I also tried npm install -g typescript@latest

Below is my 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"
}

When I try npm install I get the below message enter image description here

7
  • 1
    Try to run 'npm install' Commented Jul 28, 2017 at 6:43
  • yes I tried npm install -g typescript@latest Commented Jul 28, 2017 at 6:48
  • 1
    Not npm install -g but just npm install in your solution or or a subdirectory of it where you have your packages Commented Jul 28, 2017 at 6:50
  • What does your package.json file look like? Commented Jul 28, 2017 at 7:08
  • @Saravana added it to the question now Commented Jul 28, 2017 at 7:10

1 Answer 1

1
  1. Make sure you have run npm install on your project and the dependencies are available in the node_modules folder.

  2. In your package.json file you have dependencies with both Angular version 2 and 4. Decide which one you want to use.

If you want to use Angular version 4 your import should be:

import { Component } from '@angular/core';
Sign up to request clarification or add additional context in comments.

1 Comment

tried npm install, but looks like there is some issue with it

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.