angular.io icon indicating copy to clipboard operation
angular.io copied to clipboard

5-minute Quickstart Typescript Error Fix

Open drpalaric opened this issue 11 years ago • 27 comments

If you are following the quickstart guide, you might notice that after installing Typescript you get the following error after running the command tsc --watch -m commonjs -t es5 --emitDecoratorMetadata app.ts:

error TS5023: Unknown compiler option 'emitdecoratormetadata'.

In order to solve the problem, I ran npm install -g typescript. Maybe the tutorial should be updated if others are having the same issue.

drpalaric avatar May 08 '15 09:05 drpalaric

The quick starts says:

$ npm install -g typescript@^1.5.0-beta
$ tsc --watch -m commonjs -t es5 --emitDecoratorMetadata app.ts

That should guarantee you have the minimum supported TS version, right before you run tsc.

rkirov avatar May 08 '15 17:05 rkirov

Believe it or not, that's what I did before I got the error.

drpalaric avatar May 08 '15 17:05 drpalaric

hrm, I cannot reproduce

alexeagle-macbookpro2:~ alexeagle$ npm uninstall -g typescript
unbuild [email protected]
alexeagle-macbookpro2:~ alexeagle$ npm install -g [email protected]
/Users/alexeagle/.nvm/versions/node/v0.12.2/bin/tsc -> /Users/alexeagle/.nvm/versions/node/v0.12.2/lib/node_modules/typescript/bin/tsc
[email protected] /Users/alexeagle/.nvm/versions/node/v0.12.2/lib/node_modules/typescript
alexeagle-macbookpro2:~ alexeagle$ npm install -g typescript@^1.5.0-beta
/Users/alexeagle/.nvm/versions/node/v0.12.2/bin/tsc -> /Users/alexeagle/.nvm/versions/node/v0.12.2/lib/node_modules/typescript/bin/tsc
/Users/alexeagle/.nvm/versions/node/v0.12.2/bin/tsserver -> /Users/alexeagle/.nvm/versions/node/v0.12.2/lib/node_modules/typescript/bin/tsserver
[email protected] /Users/alexeagle/.nvm/versions/node/v0.12.2/lib/node_modules/typescript
alexeagle-macbookpro2:~ alexeagle$ tsc --version
message TS6029: Version 1.5.0-beta

alexeagle avatar May 08 '15 20:05 alexeagle

@AbdullahAlger can you run npm -v; node -v

alexeagle avatar May 08 '15 20:05 alexeagle

I have npm 2.5.1 and node 0.12.0. Maybe it's my version of npm??

drpalaric avatar May 08 '15 20:05 drpalaric

@rkirov I'll let you fix or close this issue. Assigned to you now.

alexwolfe avatar May 17 '15 18:05 alexwolfe

@AbdullahAlger

I had a similar problem on Windows 8.1 with Visual Studio installed.

If you are as well, try where tsc command. It will show you a list of TypeScript compilers installed in your system.

In my case, it was calling tsc.exe installed by Visual Studio instead of the one from the npm

I was able to by pass this error by using tsc.cmd --watch -m commonjs -t es5 --emitDecoratorMetadata app.ts instead of just tsc

WonSong avatar May 20 '15 03:05 WonSong

@WonSong

I use a Mac; however, thanks for the tip. As my original post said, I got it working by just installing

npm install -g typescript

I was just pointing out that I had trouble with the installation at npm install -g typescript@^1.5.0-beta and went around the issue myself. I am not entirely sure why the Angular tutorial would prefer npm install -g typescript@^1.5.0-beta over npm install -g typescript.

I will try again to see if the issue comes up. I've updated my npm from 2.5.1 to 2.10.0. Might be the issue, but probably not.

drpalaric avatar May 20 '15 08:05 drpalaric

I had a similar problem where it was using the "wrong" tsc with the following error: error TS5023: Unknown option 'watch' Fixed by changing tsc to tsc.cmd

Twistt avatar Jul 08 '15 00:07 Twistt

@Twistt changing it from "tsc" to "tsc.cmd" worked for me as well, thanks for posting!

tjosbon avatar Jul 08 '15 13:07 tjosbon

@rkirov I didn't see a pull request to update the documentation. Please correct me if I overlooked it. Otherwise, I'll create a quick pull request to update. Or, is this only a windows thing? I'm running the commands on a Windows 7 machine.

tjosbon avatar Jul 08 '15 13:07 tjosbon

It's a Windows thing. Regarding tsc.cmd, apparently it's a TypeScript installation issue. See SO question.

drpalaric avatar Jul 08 '15 13:07 drpalaric

@AbdullahAlger worth noting in the documentation? I had to search for this issue to discover the problem. I can pick up that task.

tjosbon avatar Jul 08 '15 14:07 tjosbon

@tjosbon Why not!? The only thing that could happen is that it's rejected.

drpalaric avatar Jul 08 '15 14:07 drpalaric

Hi, I'm getting tsc error when I type in:

Working in Windows 7 (strange) tsc.cmd --watch -m commonjs -t es5 --emitDecoratorMetadata app.ts

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

C:\projects\html5\angular2-template>tsc -m commonjs -t es5 --emitDecoratorMetada
ta app.ts
error TS5023: Unknown option 'emitDecoratorMetadata'
Use the '--help' flag to see options.
C:\projects\html5\angular2-template\typings\es6-promise\es6-promise.d.ts(7,43):
error TS1005: ',' expected.
C:\projects\html5\angular2-template\typings\es6-promise\es6-promise.d.ts(7,53):
error TS1005: '=' expected.
C:\projects\html5\angular2-template\typings\es6-promise\es6-promise.d.ts(7,56):
error TS1003: Identifier expected.
C:\projects\html5\angular2-template\typings\es6-promise\es6-promise.d.ts(7,89):
error TS1005: ',' expected.
C:\projects\html5\angular2-template\typings\es6-promise\es6-promise.d.ts(7,99):
error TS1005: '=' expected.
C:\projects\html5\angular2-template\typings\es6-promise\es6-promise.d.ts(7,102):
 error TS1003: Identifier expected.
C:\projects\html5\angular2-template\typings\es6-promise\es6-promise.d.ts(8,43):
error TS1005: ',' expected.
C:\projects\html5\angular2-template\typings\es6-promise\es6-promise.d.ts(8,53):
error TS1005: '=' expected.
C:\projects\html5\angular2-template\typings\es6-promise\es6-promise.d.ts(8,56):
error TS1003: Identifier expected.
C:\projects\html5\angular2-template\typings\es6-promise\es6-promise.d.ts(19,46):
 error TS1005: ',' expected.
C:\projects\html5\angular2-template\typings\es6-promise\es6-promise.d.ts(19,56):
 error TS1005: '=' expected.
C:\projects\html5\angular2-template\typings\es6-promise\es6-promise.d.ts(19,59):
 error TS1005: '(' expected.
C:\projects\html5\angular2-template\typings\es6-promise\es6-promise.d.ts(19,68):
 error TS1003: Identifier expected.
C:\projects\html5\angular2-template\typings\es6-promise\es6-promise.d.ts(19,109)
: error TS1005: '=>' expected.
C:\projects\html5\angular2-template\typings\es6-promise\es6-promise.d.ts(31,9):
error TS1005: '=' expected.
C:\projects\html5\angular2-template\typings\es6-promise\es6-promise.d.ts(31,25):
 error TS1003: Identifier expected.
C:\projects\html5\angular2-template\typings\es6-promise\es6-promise.d.ts(31,56):
 error TS1003: Identifier expected.
C:\projects\html5\angular2-template\typings\es6-promise\es6-promise.d.ts(31,69):
 error TS1003: Identifier expected.
C:\projects\html5\angular2-template\typings\es6-promise\es6-promise.d.ts(31,102)
: error TS1003: Identifier expected.
C:\projects\html5\angular2-template\typings\es6-promise\es6-promise.d.ts(31,103)
: error TS1005: ',' expected.
C:\projects\html5\angular2-template\typings\es6-promise\es6-promise.d.ts(31,112)
: error TS1005: '=' expected.
C:\projects\html5\angular2-template\typings\es6-promise\es6-promise.d.ts(31,115)
: error TS1003: Identifier expected.
C:\projects\html5\angular2-template\typings\es6-promise\es6-promise.d.ts(32,9):
error TS1005: '=' expected.
C:\projects\html5\angular2-template\typings\es6-promise\es6-promise.d.ts(32,25):
 error TS1003: Identifier expected.
C:\projects\html5\angular2-template\typings\es6-promise\es6-promise.d.ts(32,56):
 error TS1003: Identifier expected.
C:\projects\html5\angular2-template\typings\es6-promise\es6-promise.d.ts(32,69):
 error TS1003: Identifier expected.
C:\projects\html5\angular2-template\typings\es6-promise\es6-promise.d.ts(32,91):
 error TS1003: Identifier expected.
C:\projects\html5\angular2-template\typings\es6-promise\es6-promise.d.ts(32,92):
 error TS1005: ',' expected.
C:\projects\html5\angular2-template\typings\es6-promise\es6-promise.d.ts(32,101)
: error TS1005: '=' expected.
C:\projects\html5\angular2-template\typings\es6-promise\es6-promise.d.ts(32,104)
: error TS1003: Identifier expected.
C:\projects\html5\angular2-template\typings\es6-promise\es6-promise.d.ts(39,2):
error TS1008: Unexpected token; 'parameter' expected.
C:\projects\html5\angular2-template\typings\es6-promise\es6-promise.d.ts(39,7):
error TS1008: Unexpected token; 'parameter' expected.
C:\projects\html5\angular2-template\typings\es6-promise\es6-promise.d.ts(39,22):
 error TS1003: Identifier expected.
C:\projects\html5\angular2-template\typings\es6-promise\es6-promise.d.ts(39,55):
 error TS1003: Identifier expected.
C:\projects\html5\angular2-template\typings\es6-promise\es6-promise.d.ts(39,56):
 error TS1005: ';' expected.
C:\projects\html5\angular2-template\typings\es6-promise\es6-promise.d.ts(39,68):
 error TS1003: Identifier expected.
C:\projects\html5\angular2-template\typings\es6-promise\es6-promise.d.ts(40,1):
error TS1008: Unexpected token; 'module, class, interface, enum, import or state
ment' expected.
C:\projects\html5\angular2-template\typings\es6-promise\es6-promise.d.ts(47,32):
 error TS1005: ',' expected.
C:\projects\html5\angular2-template\typings\es6-promise\es6-promise.d.ts(47,42):
 error TS1005: '=' expected.
C:\projects\html5\angular2-template\typings\es6-promise\es6-promise.d.ts(47,45):
 error TS1003: Identifier expected.
C:\projects\html5\angular2-template\typings\es6-promise\es6-promise.d.ts(59,31):
 error TS1005: ',' expected.
C:\projects\html5\angular2-template\typings\es6-promise\es6-promise.d.ts(59,41):
 error TS1005: '=' expected.
C:\projects\html5\angular2-template\typings\es6-promise\es6-promise.d.ts(59,44):
 error TS1003: Identifier expected.
C:\projects\html5\angular2-template\typings\es6-promise\es6-promise.d.ts(59,45):
 error TS1005: '=>' expected.
C:\projects\html5\angular2-template\typings\es6-promise\es6-promise.d.ts(64,32):
 error TS1005: ',' expected.
C:\projects\html5\angular2-template\typings\es6-promise\es6-promise.d.ts(64,42):
 error TS1005: '=' expected.
C:\projects\html5\angular2-template\typings\es6-promise\es6-promise.d.ts(64,45):
 error TS1003: Identifier expected.
C:\projects\html5\angular2-template\typings\es6-promise\es6-promise.d.ts(64,46):
 error TS1005: '=>' expected.
C:\projects\html5\angular2-template\typings\rx\rx-lite.d.ts(592,75): error TS100
8: Unexpected token; 'type' expected.
C:\projects\html5\angular2-template\typings\rx\rx-lite.d.ts(592,76): error TS100
5: ']' expected.
C:\projects\html5\angular2-template\typings\rx\rx-lite.d.ts(592,85): error TS100
5: ';' expected.
C:\projects\html5\angular2-template\typings\rx\rx-lite.d.ts(592,86): error TS100
8: Unexpected token; 'call, construct, index, property or function signature' ex
pected.
C:\projects\html5\angular2-template\typings\rx\rx-lite.d.ts(592,87): error TS100
8: Unexpected token; 'call, construct, index, property or function signature' ex
pected.
C:\projects\html5\angular2-template\typings\angular2\angular2.d.ts(24,8): error
TS1005: ';' expected.
C:\projects\html5\angular2-template\typings\angular2\angular2.d.ts(25,8): error
TS1005: ';' expected.
C:\projects\html5\angular2-template\typings\angular2\angular2.d.ts(917,28): erro
r TS1005: ',' expected.
C:\projects\html5\angular2-template\typings\angular2\angular2.d.ts(917,35): erro
r TS1005: '=' expected.
C:\projects\html5\angular2-template\typings\angular2\angular2.d.ts(917,40): erro
r TS1003: Identifier expected.
C:\projects\html5\angular2-template\typings\angular2\angular2.d.ts(917,41): erro
r TS1005: '=>' expected.
C:\projects\html5\angular2-template\typings\angular2\angular2.d.ts(1544,47): err
or TS1005: '>' expected.
C:\projects\html5\angular2-template\typings\angular2\angular2.d.ts(1544,57): err
or TS1005: ',' expected.
C:\projects\html5\angular2-template\typings\angular2\angular2.d.ts(1544,63): err
or TS1005: '=' expected.
C:\projects\html5\angular2-template\typings\angular2\angular2.d.ts(1544,68): err
or TS1003: Identifier expected.
C:\projects\html5\angular2-template\typings\angular2\angular2.d.ts(1544,69): err
or TS1003: Identifier expected.
C:\projects\html5\angular2-template\typings\angular2\angular2.d.ts(2092,28): err
or TS1005: '>' expected.
C:\projects\html5\angular2-template\typings\angular2\angular2.d.ts(2092,36): err
or TS1005: ',' expected.
C:\projects\html5\angular2-template\typings\angular2\angular2.d.ts(2092,37): err
or TS1008: Unexpected token; 'parameter' expected.
C:\projects\html5\angular2-template\typings\angular2\angular2.d.ts(3150,27): err
or TS1005: '>' expected.
C:\projects\html5\angular2-template\typings\angular2\angular2.d.ts(3150,29): err
or TS1008: Unexpected token; 'constructor, function, accessor or variable' expec
ted.
C:\projects\html5\angular2-template\typings\angular2\angular2.d.ts(3150,45): err
or TS1003: Identifier expected.
C:\projects\html5\angular2-template\typings\angular2\angular2.d.ts(3163,27): err
or TS1005: '>' expected.
C:\projects\html5\angular2-template\typings\angular2\angular2.d.ts(3163,33): err
or TS1005: ';' expected.
C:\projects\html5\angular2-template\typings\angular2\angular2.d.ts(3163,44): err
or TS1005: '(' expected.
C:\projects\html5\angular2-template\typings\angular2\angular2.d.ts(3163,45): err
or TS1008: Unexpected token; 'call, construct, index, property or function signa
ture' expected.
C:\projects\html5\angular2-template\typings\angular2\angular2.d.ts(3300,86): err
or TS1005: '>' expected.
C:\projects\html5\angular2-template\typings\angular2\angular2.d.ts(3300,96): err
or TS1005: ',' expected.
C:\projects\html5\angular2-template\typings\angular2\angular2.d.ts(3300,102): er
ror TS1005: '=' expected.
C:\projects\html5\angular2-template\typings\angular2\angular2.d.ts(3300,107): er
ror TS1003: Identifier expected.
C:\projects\html5\angular2-template\typings\angular2\angular2.d.ts(3300,108): er
ror TS1003: Identifier expected.
C:\projects\html5\angular2-template\typings\angular2\angular2.d.ts(3382,48): err
or TS1005: ',' expected.
C:\projects\html5\angular2-template\typings\angular2\angular2.d.ts(3537,36): err
or TS1005: ',' expected.
C:\projects\html5\angular2-template\typings\angular2\angular2.d.ts(3545,42): err
or TS1005: ',' expected.
C:\projects\html5\angular2-template\typings\angular2\angular2.d.ts(3551,44): err
or TS1005: ',' expected.
C:\projects\html5\angular2-template\typings\angular2\angular2.d.ts(5241,25): err
or TS1005: ',' expected.
C:\projects\html5\angular2-template\typings\angular2\angular2.d.ts(5251,45): err
or TS1005: ',' expected.
C:\projects\html5\angular2-template\typings\angular2\angular2.d.ts(5251,56): err
or TS1005: ',' expected.
C:\projects\html5\angular2-template\typings\angular2\angular2.d.ts(5251,63): err
or TS1005: ',' expected.
C:\projects\html5\angular2-template\typings\angular2\angular2.d.ts(5256,44): err
or TS1005: ',' expected.
C:\projects\html5\angular2-template\typings\angular2\angular2.d.ts(5256,55): err
or TS1005: ',' expected.
C:\projects\html5\angular2-template\typings\angular2\angular2.d.ts(5256,62): err
or TS1005: ',' expected.
C:\projects\html5\angular2-template\typings\angular2\angular2.d.ts(5266,46): err
or TS1005: ',' expected.
C:\projects\html5\angular2-template\typings\angular2\angular2.d.ts(5266,57): err
or TS1005: ',' expected.
C:\projects\html5\angular2-template\typings\angular2\angular2.d.ts(5266,64): err
or TS1005: ',' expected.
C:\projects\html5\angular2-template\typings\angular2\angular2.d.ts(5378,27): err
or TS1005: ';' expected.
C:\projects\html5\angular2-template\typings\angular2\angular2.d.ts(5378,38): err
or TS1005: ';' expected.
C:\projects\html5\angular2-template\typings\angular2\angular2.d.ts(5378,45): err
or TS1005: ';' expected.
C:\projects\html5\angular2-template\typings\angular2\angular2.d.ts(5441,27): err
or TS1005: ';' expected.
C:\projects\html5\angular2-template\typings\angular2\angular2.d.ts(5441,38): err
or TS1005: ';' expected.
C:\projects\html5\angular2-template\typings\angular2\angular2.d.ts(5441,45): err
or TS1005: ';' expected.
C:\projects\html5\angular2-template\typings\angular2\angular2.d.ts(5492,39): err
or TS1005: ',' expected.
C:\projects\html5\angular2-template\typings\angular2\angular2.d.ts(5492,45): err
or TS1005: '=' expected.
C:\projects\html5\angular2-template\typings\angular2\angular2.d.ts(5492,53): err
or TS1003: Identifier expected.
C:\projects\html5\angular2-template\typings\angular2\angular2.d.ts(6159,1): erro
r TS1008: Unexpected token; 'module, class, interface, enum, import or statement
' expected.

npm -v; node -v
1.4.28 v0.10.32

brendonco avatar Jul 10 '15 05:07 brendonco

I got a error, too.

angular2/src/di/decorators.d.ts(34,13): error TS1003: Identifier expected.
angular2/src/di/decorators.d.ts(37,17): error TS1003: Identifier expected.
angular2/src/di/decorators.d.ts(45,13): error TS1003: Identifier expected.
angular2/src/di/decorators.d.ts(48,17): error TS1003: Identifier expected.
angular2/src/di/decorators.d.ts(56,13): error TS1003: Identifier expected.
angular2/src/di/decorators.d.ts(59,17): error TS1003: Identifier expected.

Env:

OS: Macintosh; Intel Mac OS X 10_10_4
node -v v0.12.7
npm -v 3.1.2
tsc -v message TS6029: Version 1.5.0-beta
[email protected]

Edit:

It is caused by

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

It's ok if using:

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

minwe avatar Jul 15 '15 06:07 minwe

same situation with @minwe

env: node -v 0.10.40 npm -v 2.13.0 [email protected] tsc 1.5.0-beta

vbilici avatar Jul 16 '15 13:07 vbilici

Have you tried installing TypeScript as npm install -g typescript Instead of version 1.5 beta? I did that and it worked for me.

drpalaric avatar Jul 16 '15 13:07 drpalaric

yep, it gives this error message: command: tsc --watch -m commonjs -t es5 --emitDecoratorMetadata app.ts error TS5023: Unknown compiler option 'emitdecoratormetadata'.

vbilici avatar Jul 16 '15 13:07 vbilici

Using tsc.cmd worked for me as I was experiencing the same thing.

benjaminmbrown avatar Jul 20 '15 18:07 benjaminmbrown