I picked node-sass implementer for libsass because it is based on node.js.

Installing node-sass

  • (Prerequisite) If you don't have npm, install Node.js first.
  • $ npm install -g node-sass installs node-sass globally -g.

This will hopefully install all you need, if not read libsass at the bottom.

How to use node-sass from Command line and npm scripts

General format:

$ node-sass [options] <input.scss> [output.css]
$ cat <input.scss> | node-sass > output.css

Examples:

  1. $ node-sass my-styles.scss my-styles.css compiles a single file manually.
  2. $ node-sass my-sass-folder/ -o my-css-folder/ compiles all the files in a folder manually.
  3. $ node-sass -w sass/ -o css/ compiles all the files in a folder automatically whenever the source file(s) are modified. -w adds a watch for changes to the file(s).

More usefull options like 'compression' @ here. Command line is good for a quick solution, however, you can use task runners like Grunt.js or Gulp.js to automate the build process.

You can also add the above examples to npm scripts. To properly use npm scripts as an alternative to gulp read this comprehensive article @ css-tricks.com especially read about grouping tasks.

  • If there is no package.json file in your project directory running $ npm init will create one. Use it with -y to skip the questions.
  • Add "sass": "node-sass -w sass/ -o css/" to scripts in package.json file. It should look something like this:
"scripts": {
    "test" : "bla bla bla",
    "sass": "node-sass -w sass/ -o css/"
 }
  • $ npm run sass will compile your files.

How to use with gulp

  • $ npm install -g gulp installs Gulp globally.
  • If there is no package.json file in your project directory running $ npm init will create one. Use it with -y to skip the questions.
  • $ npm install --save-dev gulp installs Gulp locally. --save-dev adds gulp to devDependencies in package.json.
  • $ npm install gulp-sass --save-dev installs gulp-sass locally.
  • Setup gulp for your project by creating a gulpfile.js file in your project root folder with this content:
'use strict';
var gulp = require('gulp');

A basic example to transpile

Add this code to your gulpfile.js:

var gulp = require('gulp');
var sass = require('gulp-sass');
gulp.task('sass', function () {
  gulp.src('./sass/**/*.scss')
    .pipe(sass().on('error', sass.logError))
    .pipe(gulp.dest('./css'));
});

$ gulp sass runs the above task which compiles .scss file(s) in the sass folder and generates .css file(s) in the css folder.

To make life easier, let's add a watch so we don't have to compile it manually. Add this code to your gulpfile.js:

gulp.task('sass:watch', function () {
  gulp.watch('./sass/**/*.scss', ['sass']);
});

All is set now! Just run the watch task:

$ gulp sass:watch

How to use with Node.js

As the name of node-sass implies, you can write your own node.js scripts for transpiling. If you are curious, check out node-sass project page.

What about libsass?

Libsass is a library that needs to be built by an implementer such as sassC or in our case node-sass. Node-sass contains a built version of libsass which it uses by default. If the build file doesn't work on your machine, it tries to build libsass for your machine. This process requires Python 2.7.x (3.x doesn't work as of today). In addition:

LibSass requires GCC 4.6+ or Clang/LLVM. If your OS is older, this version may not compile. On Windows, you need MinGW with GCC 4.6+ or VS 2013 Update 4+. It is also possible to build LibSass with Clang/LLVM on Windows.

Answer from Thoran on Stack Overflow
🌐
npm
npmjs.com › package › css-scss
css-scss - npm
December 13, 2017 - Convert PostCSS style CSS to SCSS. Latest version: 0.1.1, last published: 8 years ago. Start using css-scss in your project by running `npm i css-scss`. There are 10 other projects in the npm registry using css-scss.
      » npm install css-scss
    
Published   Dec 13, 2017
Version   0.1.1
Author   Brent Jackson
🌐
npm
npmjs.com › package › @adamlui › scss-to-css
@adamlui/scss-to-css - npm
August 6, 2025 - Latest version: 1.10.40, last published: 11 hours ago. Start using @adamlui/scss-to-css in your project by running `npm i @adamlui/scss-to-css`. There are 0 other projects in the npm registry using @adamlui/scss-to-css.
      » npm install @adamlui/scss-to-css
    
Published   Sep 21, 2025
Version   1.10.40
Author   Adam Lui
🌐
Sass
sass-lang.com › install
Sass: Install Sass
When you install Sass on the command line, you’ll be able to run the sass executable to compile .sass and .scss files to .css files.
Top answer
1 of 4
268

I picked node-sass implementer for libsass because it is based on node.js.

Installing node-sass

  • (Prerequisite) If you don't have npm, install Node.js first.
  • $ npm install -g node-sass installs node-sass globally -g.

This will hopefully install all you need, if not read libsass at the bottom.

How to use node-sass from Command line and npm scripts

General format:

$ node-sass [options] <input.scss> [output.css]
$ cat <input.scss> | node-sass > output.css

Examples:

  1. $ node-sass my-styles.scss my-styles.css compiles a single file manually.
  2. $ node-sass my-sass-folder/ -o my-css-folder/ compiles all the files in a folder manually.
  3. $ node-sass -w sass/ -o css/ compiles all the files in a folder automatically whenever the source file(s) are modified. -w adds a watch for changes to the file(s).

More usefull options like 'compression' @ here. Command line is good for a quick solution, however, you can use task runners like Grunt.js or Gulp.js to automate the build process.

You can also add the above examples to npm scripts. To properly use npm scripts as an alternative to gulp read this comprehensive article @ css-tricks.com especially read about grouping tasks.

  • If there is no package.json file in your project directory running $ npm init will create one. Use it with -y to skip the questions.
  • Add "sass": "node-sass -w sass/ -o css/" to scripts in package.json file. It should look something like this:
"scripts": {
    "test" : "bla bla bla",
    "sass": "node-sass -w sass/ -o css/"
 }
  • $ npm run sass will compile your files.

How to use with gulp

  • $ npm install -g gulp installs Gulp globally.
  • If there is no package.json file in your project directory running $ npm init will create one. Use it with -y to skip the questions.
  • $ npm install --save-dev gulp installs Gulp locally. --save-dev adds gulp to devDependencies in package.json.
  • $ npm install gulp-sass --save-dev installs gulp-sass locally.
  • Setup gulp for your project by creating a gulpfile.js file in your project root folder with this content:
'use strict';
var gulp = require('gulp');

A basic example to transpile

Add this code to your gulpfile.js:

var gulp = require('gulp');
var sass = require('gulp-sass');
gulp.task('sass', function () {
  gulp.src('./sass/**/*.scss')
    .pipe(sass().on('error', sass.logError))
    .pipe(gulp.dest('./css'));
});

$ gulp sass runs the above task which compiles .scss file(s) in the sass folder and generates .css file(s) in the css folder.

To make life easier, let's add a watch so we don't have to compile it manually. Add this code to your gulpfile.js:

gulp.task('sass:watch', function () {
  gulp.watch('./sass/**/*.scss', ['sass']);
});

All is set now! Just run the watch task:

$ gulp sass:watch

How to use with Node.js

As the name of node-sass implies, you can write your own node.js scripts for transpiling. If you are curious, check out node-sass project page.

What about libsass?

Libsass is a library that needs to be built by an implementer such as sassC or in our case node-sass. Node-sass contains a built version of libsass which it uses by default. If the build file doesn't work on your machine, it tries to build libsass for your machine. This process requires Python 2.7.x (3.x doesn't work as of today). In addition:

LibSass requires GCC 4.6+ or Clang/LLVM. If your OS is older, this version may not compile. On Windows, you need MinGW with GCC 4.6+ or VS 2013 Update 4+. It is also possible to build LibSass with Clang/LLVM on Windows.

2 of 4
8

npx node-sass input.scss out.css

🌐
YouTube
youtube.com › watch
Convert SCSS to CSS realtime with command-line - npm & node - YouTube
How to Convert SCSS to CSS Realtime with the command line and #node-sass package.Subscribe for New Videos:Website: https://afg...
Published   July 23, 2019
🌐
npm
npmjs.com › package › @dhunanyan › scss-to-css-converter
@dhunanyan/scss-to-css-converter - npm
November 12, 2024 - This project is a tool designed to make converting SCSS (Sassy CSS) code to CSS (Cascading Style Sheets) simple and accessible. With this converter, you can work with SCSS syntax and quickly generate the final CSS code for easy deployment and ...
      » npm install @dhunanyan/scss-to-css-converter
    
🌐
npm
npmjs.com › package › compile-sass
compile-sass - npm
October 21, 2022 - Latest version: 2.0.0, last published: 3 years ago. Start using compile-sass in your project by running `npm i compile-sass`. There are 6 other projects in the npm registry using compile-sass.
      » npm install compile-sass
    
Published   Oct 21, 2022
Version   2.0.0
Author   Alex Seifert
Find elsewhere
🌐
Spruce CSS
sprucecss.com › blog › the-simplest-sass-compile-setup
The Simplest Sass Compile Setup - Spruce CSS
September 3, 2021 - We compile our Sass files from the scss to the css folder. We don’t have to specify file names explicitly (necessarily); the script will watch for all translatable files (the ones which don’t have a _ prefix). For more information about the flags (the text in the command which stats with —), please visit the official CLI page. As you see, the npm scripts work like an alias (right now we only use the Sass CLI).
🌐
npm
npmjs.com › package › css-to-scss
css-to-scss - npm
August 12, 2018 - Latest version: 0.5.1, last published: 7 years ago. Start using css-to-scss in your project by running `npm i css-to-scss`. There are no other projects in the npm registry using css-to-scss.
      » npm install css-to-scss
    
Published   Jul 12, 2018
Version   0.5.1
Author   Alex Tsirozidis
🌐
npm
npmjs.com › package › node-sass
node-sass - npm
May 20, 2023 - It allows you to natively compile .scss files to css at incredible speed and automatically via a connect middleware. Find it on npm: https://www.npmjs.com/package/node-sass
      » npm install node-sass
    
Published   May 20, 2023
Version   9.0.0
Author   Andrew Nesbitt
🌐
Medium
hicaro.medium.com › from-sass-to-css-in-3-steps-c29adeb202db
Converting Sass to CSS in 3 Easy Steps | by Hicaro Adriano | Medium
November 30, 2020 - In the previous step, we are assuming ... (scss) is a one-time only operation. Whenever you need to compile you files just run npm run scss....
🌐
DEV Community
dev.to › evanwinter › create-your-own-css-utility-library-582d
Publishing my own CSS utility library on NPM - DEV Community
March 30, 2023 - To compile your SCSS into CSS, install the sass package from NPM as a devDependency:
🌐
Codeconcisely
codeconcisely.com › posts › compile-scss-to-css
Compiling SCSS to CSS - Code Concisely
November 23, 2022 - Now, install the following packages that Webpack uses to compile SCSS to CSS. npm i --save-dev css-loader mini-css-extract-plugin sass sass-loader
🌐
DEV Community
dev.to › sampadsarker › 5-quick-steps-transpiling-scss-to-css-using-node-with-watch-minify-mode-2mm
5 Quick Steps Transpiling SCSS to CSS Using Node (with watch & minify mode) - DEV Community
September 20, 2022 - Execute the command on terminal npm install sass · After that node_modules folder and package-lock.json file will be added the file structure. Go to the package.json file. In the scripts section remove "test": "echo \"Error: no test specified\" ...
🌐
Blogger
thecoderain.blogspot.com › 2019 › 12 › run-and-compile-sass-scss-file-to-css.html
Run and compile sass scss file to css using node
December 17, 2019 - npm install node-sass So we have installed node-sass package . Now open package.json file in your editor and add below code into it into script object · "scss": "node-sass --watch scss -o css" After adding above line your code will be look like this
🌐
npm
npmjs.com › package › scss-compile
scss-compile - npm
September 3, 2015 - A simple npm package to compile SCSS into readable CSS · Installation is super simple. Just run: npm install -g scss-compile · That's it! Running the package is also super easy.
      » npm install scss-compile
    
Published   Sep 03, 2015
Version   0.1.7
Author   Tyler A. Reckart
🌐
Devextent
devextent.com › npm-compile-sass
Compile SASS with npm | Dev Extent
January 13, 2021 - Use npm package.json scripts, node-sass npm package cli and clean-css npm package cli to compile SCSS and minify the css output with Node.js
🌐
npm
npmjs.com › package › gulp-css-scss
gulp-css-scss - npm
Gulp plugin for converting CSS to Scss. Latest version: 0.1.0, last published: 10 years ago. Start using gulp-css-scss in your project by running `npm i gulp-css-scss`. There are 15 other projects in the npm registry using gulp-css-scss.
      » npm install gulp-css-scss
    
Published   Oct 30, 2015
Version   0.1.0
Author   John Otander
🌐
Medium
medium.com › @brianhan › watch-compile-your-sass-with-npm-9ba2b878415b
Watch & Compile your Sass with npm. | by Brian Han | Medium
May 22, 2017 - Go look at your main.css file and you’ll see that node-sass indeed compiled your scss file to css. Awesome! Let’s update our scripts with a watch script. Inside package.json, make your scripts object look like this: “scripts”: { “build-css”: “node-sass --include-path scss scss/main.scss public/css/main.css”, “watch-css”: “nodemon -e scss -x \”npm run build-css\”” },