The solution to this issue has been explained in other threads, see: How to compile scss to css with node-sass

However, here's my solution using the run-watch program, nodemon:

npm install node-sass nodemon --save-dev

In package.json, add these to your "scripts":

 "build-css": "node-sass --include-path scss src/input.scss src/styles.css",
 "watch-css": "nodemon -e scss -x \"npm run build-css\" "

Then, in your "start" script, use this:

 "start": "concurrently \"node app.js\" \"npm run watch-css\" "

Next, we need to install the concurrently package:

npm install concurrently --save

To compile and serve your files,

npm start

Therefore, the "npm start" command triggers a build that starts the app and concurrently calls the "run watch-css" command which in turn calls "build-css" to compile scss to css in real-time through nodemon. It compiles and refreshes live when you edit any scss in your text editor.

Answer from anycoloryoulike84 on Stack Overflow
🌐
npm
npmjs.com › package › css-scss
css-scss - npm
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 › 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
🌐
npm
npmjs.com › package › css-to-scss
css-to-scss - npm
You can use the command css-to-scss on a css file to convert it to scss, or on an existing scss file to clean it up
      » npm install css-to-scss
    
Published   Jul 12, 2018
Version   0.5.1
Author   Alex Tsirozidis
🌐
npm
npmjs.com › package › schematics-scss-migrate
schematics-scss-migrate - npm
Latest version: 2.3.17, last published: 3 years ago. Start using schematics-scss-migrate in your project by running `npm i schematics-scss-migrate`. There are 0 other projects in the npm registry using schematics-scss-migrate.
      » npm install schematics-scss-migrate
    
Published   Mar 25, 2023
Version   2.3.17
Author   Thabo Ambrose
🌐
npm
npmjs.com › package › @adamlui › scss-to-css
@adamlui/scss-to-css - npm
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
To run Sass from anywhere on your machine, you’ll need to add the extracted dart-sass directory to your system’s PATH. For more information on how to do that, see this guide. If you use Node.js, you can also install Sass using npm by running
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

Find elsewhere
🌐
npm
npmjs.com › package › css-to-sass
css-to-sass - npm
Latest version: 0.0.1, last published: 4 years ago. Start using css-to-sass in your project by running `npm i css-to-sass`. There are no other projects in the npm registry using css-to-sass.
      » npm install css-to-sass
    
Published   Jun 26, 2020
Version   0.0.1
Author   Deniz Hacısalihoğlu
🌐
GitHub
github.com › Firebrand › css-to-scss
GitHub - Firebrand/css-to-scss: Will tidy your sass and scss
Convert plain CSS into SCSS, tidy up your existing SCSS, and more! npm install -g css-to-scss · npm install --save css-to-scss · You can use the command css-to-scss on a css file to convert it to scss, or on an existing scss file to clean ...
Starred by 11 users
Forked by 3 users
Languages   JavaScript 58.5% | CSS 41.5% | JavaScript 58.5% | CSS 41.5%
🌐
npm
npmjs.com › package › compile-sass
compile-sass - npm
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
🌐
Spruce CSS
sprucecss.com › blog › the-simplest-sass-compile-setup
The Simplest Sass Compile Setup - Spruce CSS
In this tutorial, we - and you should - use Dart Sass which is the default setting on install when we run the npm install sass command. To use npm (to install Sass), we first have to install Node.js, which we can easily do.
🌐
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....
🌐
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
🌐
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 - Create a file called index.scss and put some code like the SCSS code above into it. Run the following code, replacing "" with your actual npm username. For example, this was npm init --scope=@evanwinter for me because my username is "evanwinter".
🌐
npm
npmjs.com › package › node-sass
node-sass - npm
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
🌐
npm
npmjs.com › package › create-scss
create-scss - npm
"scripts": { "dev": "sass scss/main.scss css/style.css --watch --no-source-map", "compile": "sass scss/main.scss css/style.css --no-source-map", "minify": "sass scss/main.scss css/style.css --style=compressed --no-source-map", "add-prefixes": "postcss css/style.css -o css/style.css --use autoprefixer -b 'last 4 versions' --no-source-map", "production": "npm-run-all cs-compile cs-compress cs-prefix" }, Adapt responsive helper to match new breakpoints strategy
      » npm install create-scss
    
Published   Mar 07, 2022
Version   2.7.3
Author   Maxime Daraize
🌐
npm
npmjs.com › package › scss-compile
scss-compile - npm
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
🌐
npm
npmjs.com › package › @dhunanyan › scss-to-css-converter
@dhunanyan/scss-to-css-converter - npm
Welcome to the SCSS to CSS Converter NPM Package! This project is an NPM package designed to make converting SCSS (Sassy CSS) code to CSS (Cascading Style Sheets) simple and accessible.
      » npm install @dhunanyan/scss-to-css-converter
    
🌐
npm
npmjs.com › package › node-scss
node-scss - npm
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-scss
    
Published   Jul 25, 2021
Version   7.0.3
Author   Andrew Nesbitt