Import {} from location is not found in VS Code using TypeScript and Angular 2

2k views Asked by At

I am trying out the new Angular 2 Forms. My import statements are as follows:

import {bootstrap, onChange, NgIf, Component, Directive, View, Ancestor} from 'angular2/angular2';
import {formDirectives, NgControl, Validators, NgForm} from 'angular2/forms';

import {RegExpWrapper, print, isPresent} from 'angular2/src/facade/lang';

import {reflector} from 'angular2/src/reflection/reflection';
import {ReflectionCapabilities} from 'angular2/src/reflection/reflection_capabilities';

The 'angular2/angular2' resolves fine, but none of the other "from" locations resolve. The error is:

Cannot find module 'angular2/forms'.

All of these components are currently in my node_modules directory. If I put in the full path:

import {formDirectives, ControlDirective, Validators, TemplateDrivenFormDirective} from 'C:/Users/Deb/node_modules/angular2/forms';

then it works. However, I should not need to use the full path. Am I missing something when I set up the tsconfig or is there something else wrong?

1

There are 1 answers

1
DeborahK On

Problem was that the example application did not match with the version of Angular 2 currently available for download.

If anyone is interested, I now have a working example of Angular2 forms with TypeScript and Visual Studio Code here:

https://github.com/DeborahK/AngularU2015-Angular2Forms

Hope this helps anyone else standing on the "bleeding edge".