Homayoon
Homayoon

Reputation: 31

changing angular2/core directory not working

when i using:

import {Component} from 'angular2/core';

from app.component.ts my app will be ran successfully but compiler throw the Error:(1, 25) TS2307: Cannot find module 'angular2/core' whereas core file is in node_modules/angular2/core directory!

When I change core directory my app doesn't work but the compiler is ok! I'm working on ANGULAR: 5 MIN QUICKSTART

Project Folders Structure

my tsconfig.json:

{
  "compilerOptions": {
    "target": "es6",
    "module": "system",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": false
  },
  "exclude": [
    "node_modules",
    "typings/main",
    "typings/main.d.ts"
  ]
}

Upvotes: 0

Views: 135

Answers (1)

Thierry Templier
Thierry Templier

Reputation: 202146

You have the error since the TypeScript compiler can't find the core.d.ts file. You need to have the following configuration to make it work. Be careful to the moduleResolution attribute that must be set to node:

{
  "compilerOptions": {
    "target": "es5",
    "module": "system",
    "moduleResolution": "node", // <----------
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": false
  },
  "exclude": [
    "node_modules",
    "typings/main",
    "typings/main.d.ts"
  ]
}

Upvotes: 0

Related Questions