angular icon indicating copy to clipboard operation
angular copied to clipboard

experimentalDecorators and Cannot find module 'angular2/angular2'.

Open seanwestfall opened this issue 11 years ago • 24 comments

From the 5 Min Quickstart guide: When I'd run,

    tsc --watch -m commonjs -t es5 --emitDecoratorMetadata app.ts

I'd get this error: error TS6064: Option 'experimentalDecorators' must also be specified when option 'emitDecoratorMetadata' is specified. So, I added --experimentalDecorators to the parameters list of the above command:

    tsc --watch -m commonjs -t es5 --emitDecoratorMetadata --experimentalDecorators app.ts

But now, I get this error in the log: app.ts(1,42): error TS2307: Cannot find module 'angular2/angular2'.

Though it's not causing any sort of error to the application from the client end.

seanwestfall avatar Jul 22 '15 05:07 seanwestfall

I have what I suspect is a related bug after:

  • installing Typescript 1.5.3 (not the beta referenced in the guide) (this may be irrelevant in fact given the second point)
  • coding in Atom with typescript, where I get these errors:
at line 5, file /Users/simon/code/Dropbox/HTML/ang2/app.tsArgument of type 'typeof MyAppComponent' is not assignable to parameter of type 'Type'. Type 'MyAppComponent' is not assignable to type 'Type'. Property 'apply' is missing in type 'MyAppComponent'.
Component({
    selector: 'my-app'
})
at line 8, file /Users/simon/code/Dropbox/HTML/ang2/app.tsArgument of type 'typeof MyAppComponent' is not assignable to parameter of type 'Type'.
View({
    template: "<h1>Hello {{name}}</h1>"
})

In practise the code was compiled and ran correctly, but errors are a bit off-putting when following an introductory guide.

simonh1000 avatar Jul 26 '15 09:07 simonh1000

at line 5, file /Users/simon/code/Dropbox/HTML/ang2/app.tsArgument of type 'typeof MyAppComponent' is not assignable to parameter of type 'Type'. Type 'MyAppComponent' is not assignable to type 'Type'. Property 'apply' is missing in type 'MyAppComponent'. Component({ selector: 'my-app' }) at line 8, file /Users/simon/code/Dropbox/HTML/ang2/app.tsArgument of type 'typeof MyAppComponent' is not assignable to parameter of type 'Type'. View({ template: "<h1>Hello {{name}}</h1>" })

jmac11 avatar Jul 26 '15 12:07 jmac11

I have the same error

nicholasess avatar Aug 16 '15 03:08 nicholasess

Closing, since we are reworking the docs, and the startup sequence will change. Your errors stem from not including the d.ts file, which should have gotten from tsd step.

mhevery avatar Aug 21 '15 02:08 mhevery

How do I include the d.ts file? I got the error TS2307: 'Cannot find module angular2/angular2' after typing 'tsc -p src -w' following the "Step by step guide".

Also after trying to run the command: 'live-server --open src' in root, I get the error: 'Enoent: no such file or directory, uv_chdir ++'

Suggestions to what I might be doing wrong?

sledan avatar Sep 14 '15 14:09 sledan

getting the same error as @sledan

Error:(1, 1) TS6053: File '/home/babajide/WebStormProjects/angularTwo/typings/angular2/angular2.d.ts' not found.

jidesakin avatar Sep 14 '15 14:09 jidesakin

@sledan, @jidesakin: Check out my post on SO: http://stackoverflow.com/questions/30858164/cannot-find-external-module-angular2-angular2-angular2-w-typescript/32581715#32581715

Dunken avatar Sep 15 '15 08:09 Dunken

@Dunken: Thanks. In my editor (VS Code), in the app.ts file, the line: import {Component, View, bootstrap} from 'angular2/angular2'; - the angular2/angular2 part is still underlined red, and says it cannot find module angular2/angular2, even after the commands you suggested. I also cannot do the command in root folder: 'live-server --open src' - I still get the error: 'Enoent: no such file or directory, uv_chdir ++' The browser dont open.

Do you know what to do?

sledan avatar Sep 15 '15 10:09 sledan

@sledan @jidesakin @Dunken to solve the module errors did you run this command by chance? tsd install angular2 es6-promise rx rx-lite --save I am getting the same server when running the live-server command and have not yet figured that one out.

jgw96 avatar Sep 25 '15 02:09 jgw96

@Dunken @jgw96 try including the equals sign: live-server --open=src, it worked for me

wcbeard avatar Sep 30 '15 14:09 wcbeard

The solution by @d10genes works for me :+1: thank you live-server --open=src

bd715 avatar Oct 01 '15 10:10 bd715

also works for me, this issue can probably be closed.

jgw96 avatar Oct 07 '15 14:10 jgw96

Closing, since we are reworking the docs, and the startup sequence will change. Your errors stem from not including the d.ts file, which should have gotten from tsd step.

Well I don't see any (explicit) tsd step in the quickstart page... this is surprising following this page step by step still don't seem to be working...

cjolif avatar Nov 21 '15 07:11 cjolif

@cjolif The typings are now held in Angular2 itself, no more need for tsd.

jgw96 avatar Nov 22 '15 00:11 jgw96

@jgw96 The issue has been closed though.

seanwestfall avatar Nov 22 '15 05:11 seanwestfall

I am getting the same error! live-server --open=src i did not understand this. is it a command?

RajeswarReddy avatar May 02 '16 09:05 RajeswarReddy

Which file i have to change ?

my tsd file:

{ "version": "v4", "repo": "borisyankov/DefinitelyTyped", "ref": "master", "path": "typings", "bundle": "typings/tsd.d.ts", "installed": { "rx/rx-lite.d.ts": { "commit": "e05e1f6f83c6ac84e9d7ff8284e8089d53a788a6" }, "es6-promise/es6-promise.d.ts": { "commit": "e05e1f6f83c6ac84e9d7ff8284e8089d53a788a6" }, "rx/rx.d.ts": { "commit": "e05e1f6f83c6ac84e9d7ff8284e8089d53a788a6" } } }

RajeswarReddy avatar May 02 '16 13:05 RajeswarReddy

snip This is the error im gettting [ts] cannot find module!

RajeswarReddy avatar May 02 '16 13:05 RajeswarReddy

pls someone help me.im running this in localhost .its refusing to connect. Which file i have to change exactly.

RajeswarReddy avatar May 02 '16 13:05 RajeswarReddy

@RajeswarReddy GitHub issues are for bug reports and feature requests. For support questions please use other channels like the ones listed in CONTRIBUTING - Got a Question or Problem?

zoechi avatar May 02 '16 13:05 zoechi