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

CSS Sass Basics (retired) Getting Started with Sass Installing and Using Sass

Lucas Santos
Lucas Santos
19,315 Points

Why can't I run my SASS file???

Ok so I am in my command line and I successfully installed SASS now I'm trying to type sass test.css and it give me this message

No such file or directory

My test.scss file is in a folder in my desktop called My Test.. So my guess is that I'm not directing the file correctly.

So I guess the question would be How can I use my .scss file that is in a folder in my desktop called "My Test"?

Forgot to mention that I am on a MAC

3 Answers

craig frost
craig frost
4,592 Points

This is happening because, within terminal, you haven't changed directory to your desktop. When you first launch terminal, you'll be within your home directory, or '~'. You can return to this directory from anywhere by simply typing:

cd

or

cd ~

So, to change directory to your desktop, where your file is stored, type:

cd desktop/sass-folder-name

and type:

sass test.scss test.css

Alternatively, you can simply include 'desktop' in the path to the file. So, if you'd like to run it straight from your home directory, use:

sass /desktop/sass-folder-name/test.scss /desktop/sass-folder-name/test.css

In both cases, you're telling sass to compile the file on the left (.scss) to the file on the right (.css).

Lucas Santos
Lucas Santos
19,315 Points

I am new to Terminal so I'm not understanding.. where sass-folder-name what do I put because my folder on my desktop is called "Sass Test" exactly the way it's typed and I tried your method but it's telling me directory cannot be found

Lucas Santos
Lucas Santos
19,315 Points

it says no such file or directory.. also I don't know if I mentioned this but I am on a Mac

craig frost
craig frost
4,592 Points

It's more than likely due to the fact that you have a space in your folder name. Terminal can't interpret this space, so you'd have to escape the space with a backslash. for example, try:

cd ~/Desktop/Sass\ Test

and then try running:

sass test.scss test.css

See how you get on, and to save having to escape spaces in the future, try naming folders without a space, such as 'sass-test'.

Lucas Santos
Lucas Santos
19,315 Points

I see ok now it's working.. but another quick question... in the video he uses . as a location with --watch . where does . refer to? Also I don't see why people would ever want to use the home directory when 95% of the time you will have your files within a folder

craig frost
craig frost
4,592 Points

When using:

.

they are simply referring to the current directory you are within, and it isn't strictly needed in most cases.

Most keep their project folders within their home directory. So say you kept your web projects in a folder called 'projects' within your home directory, you could simply start your terminal and type:

cd projects

If you keep that folder within your desktop, however, you would have to type:

cd desktop/projects

Most dotfiles, such as your .bashrc, .zshrc and .vimrc also live in your home directory by default, though you won't see them via finder, as they're not visible files (due to the '.' in front of them).

Lucas Santos
Lucas Santos
19,315 Points

I see ok so if I did

cd ~/Desktop/Sass\ Test

then the . would mean /Desktop/Sass\ Test rite?

craig frost
craig frost
4,592 Points

That's right. It can be helpful when trying to select all files within the current directory.

Lucas Santos
Lucas Santos
19,315 Points

ok I see thank you very much really appreciate taking the time to help me understand... just one last concern I ran into... So when I run sass it makes a duplicate or the .scss file but in .css. How come when I ran sass --watch . rite now it made test.css AND test.css.map

what is test.css.map and why did it make that file?

Again sorry to bombard you with all these concerns I'm very new to Terminal and SASS so I apologize.

craig frost
craig frost
4,592 Points

It's perfectly alright, and there's no need to apologise, we all have to learn these things from scratch at some point.

It makes 'test.css' so that the browser can interpret the file, as the browser wouldn't know what to do with the 'test.scss' file. You'd write your Sass, compile it to CSS, and upload the CSS to your web server. This brings us onto the next issue:

What you're seeing generated there is a Sass source map, which is incredibly helpful when trying to debug CSS in the browser. It allows the browser to link up the CSS file to the Sass file, so you can find out where the error is in your Sass stylesheet. I wouldn't worry about this for the time being, but when you're ready, head over to:

https://developer.chrome.com/devtools/docs/css-preprocessors#toc-enabling-css-source-maps

and take a read. There's much more information on source maps if you search on Google, too.

Lucas Santos
Lucas Santos
19,315 Points

Oh I see ok so your never really uploading your scss file onto your server but doing it locally I guess so that it can compile the scss file into the css file that you then upload onto your server.

craig frost
craig frost
4,592 Points

That's correct. Of course, you can upload the '.scss' file to your server if you'd like to, so that it' available to download elsewhere, but you wouldn't link to it, and it wouldn't be interpreted by the browser.

Lucas Santos
Lucas Santos
19,315 Points

Craig you are the man, thanks a ton for all the help! really appreciate it

craig frost
craig frost
4,592 Points

No problem, Lucas! Have a great day.

Have you tried either having Sass watch a directory:

sass --watch path/sass-directory

Or providing Sass with a specific input:output, for example?

sass --watch test.scss:test.css
Lucas Santos
Lucas Santos
19,315 Points

Terminal is new to me so I am not understand here. Where sass-directory what do I put? I have a folder on my Desktop on my Mac thats named "Sass Test"

Lucas Santos
Lucas Santos
19,315 Points

It keeps on telling me "No such file or directory"