compass-compiler

raw JSON →
0.0.1 verified Fri May 01 auth: no javascript abandoned

A Node.js wrapper around the Ruby Compass compiler, providing a programmatic API for compiling Sass/SCSS files via Compass. Version 0.0.1 is a minimal initial release with no active maintenance. It requires Ruby and Compass to be installed on the system. The implementation is derived from grunt-contrib-compass. Use Dart Sass or node-sass for modern Sass compilation without Ruby dependencies.

error Error: spawn ruby ENOENT
cause Ruby is not installed or not in PATH.
fix
Install Ruby (e.g., via rubyinstaller.org) and ensure 'ruby' is available in your terminal.
error Could not find a Ruby executable 'ruby' on your system.
cause Compass-compiler cannot find Ruby.
fix
Add Ruby to PATH or reinstall Ruby.
error TypeError: compass.compile is not a function
cause Trying to use ESM import or destructured export incorrectly.
fix
Use CommonJS require: const compass = require('compass-compiler');
gotcha Requires Ruby and Compass to be installed globally on the system.
fix Install Ruby via https://rubyinstaller.org/ and run gem install compass
gotcha Exit code 127 means Ruby/Compass not found in PATH.
fix Ensure Ruby and Compass are installed and available in PATH.
gotcha Exit code 1 may be from 'Nothing to compile' and is not necessarily an error.
fix Check stderr for the specific message; ignore if it matches known benign output.
breaking Package is unmaintained and uses deprecated Compass (recommended replacement: Dart Sass with gulp-sass or webpack).
fix Migrate to Dart Sass; remove Compass dependencies.
npm install compass-compiler
yarn add compass-compiler
pnpm add compass-compiler

Shows how to compile Sass with Compass using options object and callback.

const compass = require('compass-compiler');

const options = {
  sassDir: './sass',
  cssDir: './css',
  outputStyle: 'expanded',
  require: ['susy']
};

compass.compile(options, function(err, result, code) {
  if (err) {
    console.error('Compilation failed:', err);
    return;
  }
  if (code === 127) {
    console.warn('Ruby/Compass not found. Install Ruby and Compass via gem install compass');
  } else if (code === 1 && !/Nothing to compile|Compass can\'t find any Sass files/.test(result.stderr)) {
    console.warn('Stderr output:', result.stderr);
  }
  console.log('Exit code:', code);
});