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

Install typeScript :)

i did $ npm install -g typescript and it seemed like everything worked

but when I ask for version $tsc -v

it says -bash: tsc: command not found

what up?

2 Answers

rydavim
rydavim
18,814 Points

Can you try running the npm install with the --verbose flag? That will hopefully provide more information we can use to help figure out what might be going wrong.

line this? --->$ npm install -g typescript --verbose

OK, that spat out a bunch of stuff. What should I be looking for? An error?

I have a mac. I have Visual Studio Code as well and as far as I know VScode comes with some sort of typescript integration. I have gone all the way down to /root to search for $tsc -v (or) $typescript -v (or) $tsc -version etc...

... ok wait, I found it here. /Users/jesselawson/.node_modules_global/lib/node_modules/typescript

and tsc is in /.node_modules_global/bin/tsc

Are these in the proper place?

Placing modules and libraries and all that is very new to me. I've been focusing on Javascript language and not so much the file structure and hierarchy.

rydavim
rydavim
18,814 Points

It sounds like it might not be in your path.

Can you type the command echo $PATH and let me know the result?

Mine looks like: /Users/Rydavim/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:.

Users/jesselawson/.rbenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/usr/local/git/bin

it's strange. I can see typescript in /.node_modules_global/lib/node_modules/ $ls -a bower crunt-cli typescript npm-debug.log yeoman-doctor but I can't check the typescript version

rydavim
rydavim
18,814 Points

Okay! Sorry this exchange is so delayed, hopefully we can figure this out today. I've got a couple more things for you to run, let me know what they output.

ls -l /usr/local/bin/tsc (There should be a symlink here if typscript was installed globally.)

ls -l /usr/local/lib/node_modules/typescript/bin/tsc (This is where I would expect typescript to be installed.)

If both of those come back as "no such file or directory" that's...fishy. So one more thing to run if that happens...

ls -l /usr/local (This will give you a list with permissions, we only need the bin line.)

The bin permissions should look like drwxrwxr-x. If they don't, let me know. Are you running El Capitan?

yes I'm running El Capitan

ls -l /usr/local/bin/tsc <!-- no such filr or directory--> ls -l ls -l /usr/local/lib/node_modules/typescript/bin/tsc <!-- no such filr or directory-->

and permissions for usr/local show drwxrwxr-x for bin

drwxrwxr-x 31 jesselawson admin 1054 Nov 2 16:31 bin

rydavim
rydavim
18,814 Points

Well, that's weird. You might want to just add the directory where you found it to your PATH. That should solve your issue, but it doesn't explain why it's not in the default directory.

If you're still interested in figuring out why it's wonky, try npm list -g --depth=0 to get a list of globally installed packages. If typescript isn't listed, I fear Visual Studio Code has some impact on where npm installs global modules.

Part of the issue may be that VSC ships with typescript 1.6.2, so you probably already had it when you ran the install.

It could also be some kind of permissions issue due to El Capitan's new Systems Integrity Protection, which can cause issues for developers. If --verbose didn't get you any errors, this is probably not the issue though.