Node Bourbon
Node Bourbon is a `node-sass` wrapper for the now-unmaintained Bourbon Sass library. It provided a convenient way for Node.js developers to integrate Bourbon's Sass mixins and functions into their projects using `node-sass` (which itself is a binding for LibSass). The package reached its last stable version, 4.2.8, in March 2016. Since then, both `node-bourbon` and the original Bourbon project by thoughtbot have been abandoned. The original Bourbon library recommends transitioning to native CSS. Consequently, `node-bourbon` is not compatible with modern Sass compilers like Dart Sass or recent versions of Node.js, making it unsuitable for new projects and difficult to maintain in existing ones.
Common errors
-
Error: File to import not found or unreadable: bourbon
cause The Sass compiler (node-sass) could not locate Bourbon's stylesheet files. This often happens if `node-bourbon`'s `includePaths` are not correctly passed to the Sass compiler's options, or if `node-bourbon` itself is not installed correctly.fixEnsure `require('node-bourbon').includePaths` (or `.with()`) is correctly assigned to your Sass compiler's `includePaths` option in your build configuration (e.g., Gulp, Grunt, Webpack). Verify `node_modules/node-bourbon` exists and contains the expected files. -
Invalid CSS after "v": expected 1 selector or at-rule, was "var path = require("cause This error occurs when a JavaScript file is mistakenly treated as a Sass file by the compiler. It typically happens if your build tool's glob pattern for Sass files accidentally includes `node-bourbon`'s `index.js` or another JavaScript file.fixReview your `gulp.src()`, `grunt.initConfig().files`, or Webpack loader configurations to ensure only actual `.scss` or `.sass` files are processed by the Sass compiler. Exclude `node_modules` directories explicitly if necessary. -
WARNING: [Bourbon] [Deprecation] *** is deprecated and will be removed in 5.0.0.
cause You are using a deprecated Bourbon mixin or function from an older version of Bourbon that `node-bourbon` wraps (Bourbon v4.x). These deprecation warnings were present in the original Bourbon library.fixUpdate your Sass code to use the recommended alternatives for the deprecated Bourbon features. Given that Bourbon itself is unmaintained, this might involve migrating away from Bourbon entirely to native CSS or more modern Sass practices.
Warnings
- breaking The `node-bourbon` package is effectively abandoned, with its last release over 10 years ago. It is built to wrap an older, also unmaintained version of the Bourbon Sass library (v4.x). Modern Sass environments (Dart Sass) and newer Node.js versions are not officially supported.
- breaking This package exclusively relies on `node-sass` (LibSass), which itself is deprecated and no longer actively developed. It will not work with the modern `sass` package (Dart Sass) without careful configuration or potential breakage.
- gotcha Earlier versions and even 4.2.7/4.2.8 had issues with returning incorrect or nested Bourbon paths, potentially leading to 'file not found' errors during Sass compilation.
- gotcha `node-bourbon` is explicitly NOT tested against the Ruby version of Sass. Using it with `grunt-contrib-sass` (which typically invokes Ruby Sass) may lead to unexpected behavior or compilation failures.
Install
-
npm install node-bourbon -
yarn add node-bourbon -
pnpm add node-bourbon
Imports
- bourbon
import bourbon from 'node-bourbon';
const bourbon = require('node-bourbon'); - bourbon.includePaths
require('node-bourbon')require('node-bourbon').includePaths - bourbon.with()
require('node-bourbon').withrequire('node-bourbon').with('path/to/extra/scss')
Quickstart
const gulp = require('gulp');
const sass = require('gulp-sass')(require('sass')); // Using 'sass' for modern compatibility, though node-bourbon expected node-sass
const path = require('path');
gulp.task('sass-compile', function () {
return gulp.src('src/styles/*.scss')
.pipe(sass({
// The primary way to include Bourbon paths is via includePaths
includePaths: require('node-bourbon').includePaths
// Alternatively, to include additional directories alongside Bourbon's:
// includePaths: require('node-bourbon').with(path.join(__dirname, 'src/components'))
}).on('error', sass.logError))
.pipe(gulp.dest('dist/css'));
});
// To run this, ensure you have gulp, gulp-sass, sass (Dart Sass) and node-bourbon installed.
// You'll also need a 'src/styles/main.scss' file, e.g.:
//
// /* src/styles/main.scss */
// @import "bourbon";
//
// body {
// @include display(flex);
// background-color: #f0f0f0;
// }
//
// Run with: `npx gulp sass-compile`