sass-include-paths
raw JSON → 4.10.0 verified Sat Apr 25 auth: no javascript
Generates include path arrays for node-sass from npm, bower, Ruby gem, and Bundler sources. Version 4.10.0 (stable, no recent updates). Enables interoperability between Ruby Sass, LibSass, and Eyeglass by scanning node_modules, bower_components, and gem directories for SCSS/SASS packages. Differentiator: provides both async (Promise-based) and sync variants for tools like Gulp. Note: Ruby gem scanning requires a Ruby environment; bower support is legacy.
Common errors
error Cannot find module 'sass-include-paths' ↓
cause Package not installed or import path incorrect.
fix
Run npm install sass-include-paths --save-dev and use correct import (see imports section).
error TypeError: nodeModulesSync is not a function ↓
cause Using default import incorrectly or destructuring from wrong object.
fix
Use import { nodeModulesSync } from 'sass-include-paths'
error Error: ENOENT: no such file or directory, scandir '/path/to/gems' ↓
cause Ruby gem bundle path does not exist or is misconfigured.
fix
Verify the bundle path (default ./vendor/bundle) or customize via options.
Warnings
gotcha bower support is legacy and may be removed in future versions. ↓
fix Avoid relying on bowerComponents or bowerComponentsSync if possible.
gotcha Ruby gem scanning requires a working Ruby environment and may fail silently if gems are not activated. ↓
fix Ensure Ruby and gems are installed and PATH is set correctly.
gotcha Async methods return Promises and must be awaited or chained; calling them synchronously will not return the array. ↓
fix Use the Sync variant or await the async method.
gotcha The module does not support custom package managers or scoped npm packages automatically. ↓
fix Manually add paths for scoped packages or other package managers.
Install
npm install sass-include-paths yarn add sass-include-paths pnpm add sass-include-paths Imports
- nodeModulesSync wrong
const nodeModulesSync = require('sass-include-paths').nodeModulesSynccorrectimport { nodeModulesSync } from 'sass-include-paths' - nodeModules wrong
const nodeModules = require('sass-include-paths').nodeModulescorrectimport { nodeModules } from 'sass-include-paths' - rubyGemsBundle wrong
import rubyGemsBundle from 'sass-include-paths'correctimport { rubyGemsBundle } from 'sass-include-paths' - bowerComponentsSync wrong
const bowerComponentsSync = require('sass-include-paths/bowerComponentsSync')correctimport { bowerComponentsSync } from 'sass-include-paths'
Quickstart
import { nodeModulesSync, rubyGemsSync } from 'sass-include-paths';
const includePaths = []
.concat(nodeModulesSync())
.concat(rubyGemsSync());
console.log('Include paths:', includePaths);
// Usage with node-sass:
// const sass = require('node-sass');
// const result = sass.renderSync({
// file: 'main.scss',
// includePaths: includePaths
// });
// console.log(result.css.toString());