The `sass` npm package provides a pure JavaScript implementation of the Sass preprocessor, enabling developers to compile SCSS and Sass files into CSS. It is currently at version 1.99.0 and receives frequent, iterative updates, with new features and bug fixes released regularly as seen in its changelog. This package is a compilation of Dart Sass to JavaScript, making it highly portable with no native dependencies, unlike `node-sass` which relies on LibSass (C++). It offers both a command-line interface and a Node.js API, featuring modern asynchronous and synchronous `compile` functions for transforming Sass code. While it maintains a legacy API compatible with `node-sass` (`render`, `renderSync`), this API is deprecated and slated for removal in Dart Sass 2.0.0, distinguishing its usage patterns from older Sass integrations. Its key differentiators include platform independence, official support from the Sass team, and predictable evolution, providing a robust and evolving solution for CSS preprocessing in JavaScript environments.
npm install sassVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates both synchronous (`compile`) and asynchronous (`compileAsync`) compilation of a simple SCSS string into CSS, writing the output to temporary files. It showcases common Sass features like variables and nesting, and cleans up after execution.
Rewrite compilation logic to use `sass.compile()` or `sass.compileAsync()`. Refer to the Sass JS API documentation for the new signature and options, as they differ significantly from the legacy API.
Benchmark both `compile()` and `compileAsync()` for your specific use case to determine the optimal choice. For local file system compilation, `compile()` is often the faster option, while `compileAsync()` remains beneficial for non-blocking operations in larger build processes.
When migrating from `node-sass`, ensure these deprecated options are removed or replaced. `precision` is handled automatically by Dart Sass, and `sourceComments` is superseded by source maps (the default behavior for `compile` and `compileAsync`).
Always install `sass` for modern Sass compilation in JavaScript environments. Avoid `node-sass` for new projects, and consider migrating existing projects due to its lack of updates, potential installation issues with native dependencies, and differing feature sets.
Update your code to use the modern `compile()` or `compileAsync()` functions. The API signatures and return types are different, so carefully consult the official Sass JS API documentation.
Remove the `outputStyle` option if it's not 'expanded' or 'compressed'. Remove `precision` and `sourceComments` options entirely, as they are not supported by Dart Sass's legacy API and will cause errors.
Run `npm install sass` or `yarn add sass` in your project directory. If using a global executable, ensure it's installed via `npm install -g sass` and your system's PATH variable is correctly configured.
Ensure all variables are defined before use. Check for typos in variable names or verify that the file containing the variable definition is correctly imported using `@use` or `@forward` (preferred) or `@import` (legacy).
No dependency data recorded yet.