Typescript: tsc command not working in 3.2.1 - Expected identifier

Created on 30 Nov 2018  Â·  21Comments  Â·  Source: microsoft/TypeScript


TypeScript Version: 3.2.1


Search Terms: Expected identifier

Code

// Start a command line and just write tsc or tsc -v

Expected behavior: display the current version or the info

Actual behavior: It raises a Windows Script Host error (check image)
typescript_3_2_error

I checked the installation folder and there is just a tsc.js file. The tsc.exe is missing
The npm works fine. It is the TypeScript_SDK.exe for VS 2017 what fails.

Playground Link:

Related Issues:
SO: Windows 10 1809 10.0.17763.107

Visual Studio

Most helpful comment

Yes we removed tsc.exe in 3.2 so this exact method of invocation wouldn’t work anymore. A command like node.exe full_path_to_tsc.js would work.

What is your exact scenario and goal here? We may need to update some docs depending on what you’re trying to achieve.

All 21 comments

We stopped shipping tsc.exe in the SDK AFAIK - @minestarks ?

Yes we removed tsc.exe in 3.2 so this exact method of invocation wouldn’t work anymore. A command like node.exe full_path_to_tsc.js would work.

What is your exact scenario and goal here? We may need to update some docs depending on what you’re trying to achieve.

Yes we removed tsc.exe in 3.2 so this exact method of invocation wouldn’t work anymore. A command like “node.exe full_path_to_tsc.js” would work.

What is your exact scenario and goal here? We may need to update some docs depending on what you’re trying to achieve.

Thanks for the info.
I was just trying to check wether the PATH was pointing to the correct folder or not. So this "issue" is not something that blocks any kind of project I am doing at the moment.

Come to think of it, given that there's no executable on the %PATH% anymore, I wonder if we should stop adding ourselves to the path too.

Our applications relied on tsc.exe being shipping with the SDK, and this is a pretty big breaking change for us. Can we not run tsc now without installing Node? If so, we're hoping for a slimmed-down version that doesn't require us to install Node and all of its node modules...

You can download node.exe as a standalone executable from https://nodejs.org/ - it doesn't have any dependencies.

@pushkin- Can you tell me more about your build setup and any drawbacks to the switchover? I'd like to understand it more so we can add it to our considerations in the future

@minestarks Well, node ships with npm, which has various node dependencies (the nodejs folder is about 50 MB on my machine).

Also, it looks like VS2017 ships with node? I found one here: "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\ServiceHub\Hosts\ServiceHub.Host.Node.x86"

Can we just use that node.exe, instead of installing another one?

Well, this might not be as big of a deal as I thought. Mainly we have a tool that searches for tsc.exe and transpiles our TS files with various arguments. Can we just pass those same arguments to tsc.js and it'll work as before, or no?

@minestarks Is there some documentation on how to migrate from the old tsc.exe --args command to node.exe tsc.js --args command?

node.exe tsc.js should be equivalent to tsc.exe so you can pass the same arguments to either.

This would be a good thing to document properly. We'll work on it.

VS2017 does include node.js - and the one at MSBuild\Microsoft\VisualStudio\NodeJs\node.exe is automatically used when you are using MSBuild and our Nuget package / MSBuild targets to build. You can update your scripts to point to that one (the one you linked is used for other scenarios and I can't make guarantees about it). For the most seamless transition you'd want to be using the Nuget package to build, but it sounds like you have a more custom setup (I'm still interested to learn more details about it).

@minestarks I didn't find a NodeJs directory in my Program Files (x86)/MSBuild/Microsoft/VisualStudio. I did find node.exe in:

Program Files (x86)/Microsoft Visual Studio/2017/Professional/Web/External/Node.exe
(and in External/x86/Node.exe)

Are those suitable alternatives?


I have a tool that uses tsc.exe to generate declaration files for our namespaced-Typescript code.

@pushkin- looks like you may be using an older version of VS? I say take the dependency at your own risk, when you upgrade VS you may lose those paths. I think your safest bet might be to get node.exe from https://nodejs.org/ and put it in a known location.

@minestarks Maybe I'll install my own Node then. Is there a particular version of Node that needs to be used? Is that documented anywhere by chance?

I know for sure it's known to be working with Node v10 , but I'm actually not sure of the officially supported Node.js version range - @RyanCavanaugh do we have guidance on that?

@pushkin- Feedback noted on the lack of clear documentation .

@minestarks Oh I see - when you said Node is located in MSBuild/, you weren't talking about the top-level MSBuild/ in Program Files (x86), but the one in "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\", right?

After updating to 15.9.7, I see it now.

Do you happen to have any information on which version of Visual Studio put node.exe in that location?

The Visual Studio on my other machine (15.8.1) does not have a NodeJS directory in "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Microsoft\VisualStudio".

@pushkin- Yes we moved it around in 15.9 to make it available in the VS Build Tools SKU as well.

While that location should be stable for 15.9 if you have to use it, I will say it's intentionally undocumented and intended to be known to VS components only. If you don't intend on moving off of 15.9, probably OK for now to use that path.

@RyanCavanaugh Can you speak to which Node versions are supported by the tsc.js in TypeScript 3.3? Will something like 8.11 work, or does it need to be >=10? Thanks

@minestarks Do you know if using a different Node version could produce different results (re: transpiled code)? If so, that could be a problem for me.

I found a Microsoft.TypeScript.targets directory, which contains various possible Node paths - maybe I should just use those.

Our CI server runs Node 8, 10, and 11, though we were running Node 6 as well until very recently. So 8 / 10 / 11 are "officially" supported in that regard and I'd expect Node 6 to "happen to work" for at least a little while longer.

If something did break on an unsupported version, it would be fairly obvious (e.g. crash); we've never had a "different output" situation from varying node versions. So you're fairly safe running any version which appears to work.

How to solve this error any help?I am unable to use typescript!
tscerror

How to solve this error any help?I am unable to use typescript!
tscerror

You have to addd the typescript bin folder to the PATH so it can be run from the command line

I actually installed node in E drive. and not in C drive.So after
installing node in C drive. I no longer get that error.

On Thu, 12 Sep 2019 at 16:00, blfuentes notifications@github.com wrote:

How to solve this error any help?I am unable to use typescript!
[image: tscerror]
https://user-images.githubusercontent.com/40171349/64775982-fd0e3480-d574-11e9-82e0-eac80bfaa2f0.PNG

You have to addd the typescript bin folder to the PATH so it can be run
from the command line

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/microsoft/TypeScript/issues/28761?email_source=notifications&email_token=AJSPOVP4VZ5U4QJAN7VXR43QJIK2VA5CNFSM4GHMUS3KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6RNKMI#issuecomment-530765105,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AJSPOVKAJ2F4Y7IOPPFYIADQJIK2VANCNFSM4GHMUS3A
.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dlaberge picture dlaberge  Â·  3Comments

bgrieder picture bgrieder  Â·  3Comments

blendsdk picture blendsdk  Â·  3Comments

jbondc picture jbondc  Â·  3Comments

Zlatkovsky picture Zlatkovsky  Â·  3Comments