Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript TypeScript Basics Getting Started with TypeScript Setting Up a Simple TypeScript Project

Alisar Fares-Boulos
Alisar Fares-Boulos
202 Points

could you please explain how to use the compiler if you did not install typescript globally? thanks

I tried "npx tsc" to compile to js but "export" keeps throwing a unexpected token error.

1 Answer

Travis Alstrand
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Travis Alstrand
Treehouse Project Reviewer

It's a bit hard to tell without having your project on hand, but did you happen to write your filename after npx tsc?

Here's what I found after some Googling :smile:

Since you are getting an "unexpected token" error related to the export keyword, it is likely because your environment doesn't support the version of JavaScript that includes export and import. Could you try adding the following line to the top of your TypeScript file?

export {};

This will create a module in your file, which will allow you to use export and import statements.

Alisar Fares-Boulos
Alisar Fares-Boulos
202 Points

My mistake, I see now that it's written further up the error msg that I needed to add "type": "module" to package.json. Thanks for the help!