Install Dart Sass

Dart Sass is the primary implementation of Sass. It can be installed as a command-line tool or as a project dependency through npm.

For JavaScript projects, installing Sass locally makes the compiler version part of the project's dependency configuration. Team members and CI pipelines can then use the same declared dependency version.

A typical project can keep source files under src/scss and generated files under public/css. Other directory structures are equally valid as long as the build configuration references the correct paths.

After installation, the sass executable becomes available through npm scripts or package-manager execution tools.

Specifications & Requirements
  • Compiler:Dart Sass
  • Package:sass
  • Dependency type:Development dependency for typical frontend builds
Initialize a Project and Install Sass
npm init -y
npm install --save-dev sass
npx sass --version
mkdir -p src/scss public/css
💡 The first command creates a package.json file. The second installs Sass as a development dependency because compilation is generally a build-time task. The third verifies the installed compiler. The final command creates example source and output directories on Unix-like environments. On Windows, create the directories using File Explorer or the appropriate PowerShell commands.
Knowledge Check

Which npm package is the standard choice for compiling Sass in a modern JavaScript project?