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 Angular Basics Setting Up an Angular Application Your First Angular Application

I'm getting a syntax error when entering: $ git:(master) code . -bash: syntax error near

I have a Mac. I downloaded Xcode and installed Homebrew. Then I installed Node and NPM via the command line. I downloaded Visual Code Studio. Then I installed Typescript from the command line with npm install -g typescript I'm not sure if I've done all this correctly or not. Now whey I try to follow Andrew's initial directions for the photoblog project, I keep getting a syntax error as shown above.

(I wish Treehouse would add another module to this course spending a little more time on how to set all this up to get started. The photoblog file name used in the video doesn't match the one in the downloads section either which is photo_blog.)

Nathan Brenner
Nathan Brenner
35,844 Points

Can you provide the full bash error with the markdown code highlighter? Just add one backtick before and after your code like this:

my code

7 Answers

Nathan Brenner
Nathan Brenner
35,844 Points

Yep, that's it, you just need to type

code .

The git:(master) isn't part of the command, it's just part Andrews command line prompt, which in his case he does have Oh-my-zsh installed, which is different from bash, and has nothing to do with this course. code starts VS Code. Anything after that is the path to what you want to open VS Code to, like in this case, the root of the project directory.

Nathan Brenner
Nathan Brenner
35,844 Points

Hi John, I'm also on a mac, and I'm using Terminal.

To check if you downloaded node, typescript, and npm correctly, you can run node --version, tsc --version, and npm --version. All of those commands in your shell should return something like Version 2.2.1 or an error, which probably represents an error in how the program was installed or that it hasn't been installed yet.

code . in the shell should open up Visual Studio Code at the root of your current path. For example, from the terminal,, if you ran pwd (short for print working directory), you might see something like /Users/yourusername/Documents/photo_blog. Alternatively, you could open VS Code from where Applications, or by typing command + space, then code in the input field to locate VS Code. Then, with VS Code open, you could go to the File top navigation menu and select Open.

Nathan, No, I'm not using OhMyZsh.

I'm just following the directions Andrew provides in the video.

I followed your directions, "From inside VS Code, type command + shift + p, then type shell, and select Shell Command: Install 'code' command from PATH. On success, you should then be able to run code . from your Terminal."

It seemed to work fine in VS Code and advised it installed, but when I ran it in Terminal, I still receive the same syntax error.

Last login: Sat Mar 18 17:43:54 on ttys000
Johns-MacBook-Pro:~ johnhendrix$ cd angular-basics/photo_blog
Johns-MacBook-Pro:photo_blog johnhendrix$ git:(master) code .
-bash: syntax error near unexpected token `master'
Johns-MacBook-Pro:photo_blog johnhendrix$ 
Nathan Brenner
Nathan Brenner
35,844 Points

Can you open VS Code from Applications?

When you downloaded the project, did you click on the Starter Project Zip File link, then unzipped the file and moved it to a location you could easily access it from like the Desktop directory or another directory like Documents?

In terminal, I typed, "code ." without the "git:(master)" and it opened VS Code! So why is Andrew putting git:(master) in front of the "code ." command?

He isn't putting "git:(master)" there, git's cmd is. When you are inside of Visual Studio Code, you can select the default cmd. One choice would be git bash cmd and from here you can use the command: "git checkout master" to check out the master branch.

This command will then present the working directory followed by the (master) part just indicating the current git branch being followed.

This is not a necessary step to complete this tutorial but easily a confusing part if your screen looks a tad different than your instructor's.

Sure Nathan, Here it is:

Johns-MacBook-Pro:photo_blog johnhendrix$ git:(master) code .

-bash: syntax error near unexpected token `master'

Johns-MacBook-Pro:photo_blog johnhendrix$
Nathan Brenner
Nathan Brenner
35,844 Points

You're using OhMyZsh right? That's why you can see the (master), which is an indication on which git branch you're working from.

It sounds like you don't have the code command in your path, which is supposed to get added when you install VS Code, and I've had that issue a few times. From inside VS Code, type command + shift + p, then type shell, and select Shell Command: Install 'code' command from PATH. On success, you should then be able to run code . from your Terminal.

All the versions are installed.

Johns-MacBook-Pro:~ johnhendrix$ node -v
v7.7.3
Johns-MacBook-Pro:~ johnhendrix$ tsc -v
Version 2.2.1
Johns-MacBook-Pro:~ johnhendrix$ npm -v
4.1.2

Okay, thanks Nathan. I was taking everything too literal and trying to follow all his rushed setup. I overcomplicated it thinking I had to use his special Git command after installing all these new packages in Terminal to get started.

Of course, I probably should have realized that I could have just opened VS Code like any other application and then used File->Open to open the project.

I've wasted two days on this silliness just trying to get started using VS Code with Angular. Live and learn!

Thanks Nathan. Hopefully my question and your answers will help someone else get started a little quicker! ?

Nathan Brenner
Nathan Brenner
35,844 Points

?

When you have the bandwidth, check out http://ohmyz.sh/