Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.

Join them; it only takes a minute:

Sign up
Join the Stack Overflow community to:
  1. Ask programming questions
  2. Answer and help your peers
  3. Get recognized for your expertise

This app uses jspm for javascript module loading, so all of the angular2 typescript definition files are in jspm_modules folder. I get errors that Typescript cannot find module 'angular/core', 'angular/route', 'angular/http', etc. I get the error both in VS 2015 editor and when I run my build, which is using gulp-typescript. I thought maybe it's because I have jspm_packages in my tsconfig.json:

{
  "version": 3,
  "compilerOptions": {
    "target": "es5",
    "module": "system",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": false
  },
  "exclude": [
    "node_modules",
    "wwwroot/jspm_packages",
    "wwwroot/app"
  ]
}

But if I remove that line, I get all kinds of duplicate names errors. I've tried editing my xproj file as suggested in other similar questions, but to no avail. Any ideas how to fix this problem?

enter image description here

The source code is available on github.

https://github.com/ryanlangton/angular2-asp5-starter/tree/typescript-errors

share|improve this question
    
I think an npm install in the package.json directory should fix this. TypeScript Compiler will find type definition automatically in your node_modules – Herrington Darkholme Jan 20 at 7:05
up vote 0 down vote accepted

I think an npm install in the package.json directory should fix this. TypeScript Compiler will find type definition automatically in your node_modules.

The problem is that dependency resolution is two-folded in a JSPM powered Angualr2 apps.

The compiling phase, which is gulp-typescript in this case, will find Angular2 module accroding to typescript compiler's rule. tsc will conventionally follow typing files in node_modules. So if you install Angular2 by npm locally, gulp-typescript will resolve it correctly.

The runtime phase is totally a different story, though. In browser all dependencies are resolved by jspm, which configured by config.js. Your typescript is compiled to javascript, so tsc does not interfere here. Systemjs will find angular2 in jspm_packages.

So, it seems your compiling phase dependencies are not installed. Try with npm install?

share|improve this answer
    
So sad, jspm is not npm compatible :(. Usually you need install one module twice in both jspm and npm – Herrington Darkholme Jan 20 at 7:15

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.