1

I am trying to build a Angular2 application using TypeScript in Visual Studio. I followed the steps shown in "5 min Quickstart" in angular2 site.(https://angular.io/guide/quickstart). But I got the following error as shown in following picture enter image description here

Can anyone Help me to fix the issue "Cannot find name 'Map'? thanks a advanced the package.json file definition is as follows

{
  "name": "angular2-quickstart",
  "version": "1.0.0",
  "scripts": {
    "start": "tsc && concurrently \"npm run tsc:w\" \"npm run lite\" ",
    "lite": "lite-server",
    "postinstall": "typings install",
    "tsc": "tsc",
    "tsc:w": "tsc -w",
    "typings": "typings"
  },
  "license": "ISC",
  "dependencies": {
    "@angular/common":  "2.0.0-rc.2",
    "@angular/compiler":  "2.0.0-rc.2",
    "@angular/core":  "2.0.0-rc.2",
    "@angular/http":  "2.0.0-rc.2",
    "@angular/platform-browser":  "2.0.0-rc.2",
    "@angular/platform-browser-dynamic":  "2.0.0-rc.2",
    "@angular/router":  "2.0.0-rc.2",
    "@angular/router-deprecated":  "2.0.0-rc.2",
    "@angular/upgrade":  "2.0.0-rc.2",
    "systemjs": "0.19.27",
    "core-js": "^2.4.0",
    "reflect-metadata": "^0.1.3",
    "rxjs": "5.0.0-beta.6",
    "zone.js": "^0.6.12",
    "angular2-in-memory-web-api": "0.0.12",
    "bootstrap": "^3.3.6"
  },
  "devDependencies": {
    "concurrently": "^2.0.0",
    "lite-server": "^2.2.0",
    "typescript": "^1.8.10",
    "typings":"^1.0.4"
  }
}
2
  • Even I had a similar issue with Visual Studio 2015. But, my code compiled even though map is showing error in IDE. Try compiling using command prompt and use Visual Studio Code. That might help. Commented Jun 21, 2016 at 8:59
  • Have you included tsconfig.json? And does it have "sourceMap": true ? Commented Jun 21, 2016 at 9:03

3 Answers 3

3

I had to change VS file as documented here typescriptServices.js

Invalid module name in augmentation #8518

I see the issue now. this is a duplicate of #7415, and should be fixed in the next release (see #7507).

As work arounds for now, you can replace C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TypeScript\typescriptServices.js with the file in https://raw.githubusercontent.com/Microsoft/TypeScript/Fix8518/lib/typescriptServices.js. First take a local backup though.

This is related to VS 2015, but somewhere below should be also some solution for VS 2013

Sign up to request clarification or add additional context in comments.

2 Comments

try to exclude the node_modules folder in your tsconfig.json file
I've been working on this problem all day. I tried (1) installing latest node 3.10.3 and npm 6.3.0 (2) installed latest typescript for Visual Studio 2015 - v1.8.6 (3) Installed latest update 3 of VS. Nothing helped. This finally got rid of the red squigglies.
0

After googling a lot at last i found the solution and i want to share it with all of you just add the following line at the top of component .ts file

///<reference path="../node_modules/angular2/typings/browser.d.ts"/>

just see the picture below

enter image description here

Update
if you use anguler2 beta(angular2/core) then you should add

///<reference path="../node_modules/angular2/typings/browser.d.ts"/>

but if you use angular2 rc1/rc2/rc3(@angular2/core) the you should add

/// <reference path="../node_modules/typescript/lib/lib.es6.d.ts" />

Comments

0

To fix this issue you open your typings.d.ts and comment the below lines Comment out the below code, it will fix your problem.

//declare var module: {
//  id: string;
//};

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.