Vite cannot find the sass preprocessor you import
Internal server error: Preprocessor dependency "sass" not found. Did you install it?Short answer
Vite compiles .scss and .sass files but does not ship the compiler. Install sass-embedded or sass in the project that runs Vite, as a dev dependency. If it works locally and fails in CI or a Docker build, the install skipped devDependencies, so include them for the build.
Fix it fast
1Find out which cause you have
Check whether a sass package is installed in the folder that runs Vite, and whether your install step leaves out dev dependencies.
npm ls sass sass-embedded echo "NODE_ENV=$NODE_ENV"2Match what you see, then jump to its fix
What does the error look like?
Internal server error: Preprocessor dependency "sass" not found. Did you install it?The same message during vite build in CI or Docker, although it works on your machine
Cause 1 of 2
No Sass compiler is installed
1Check
The Vite docs say .scss, .sass, .less and .styl files work without Vite plugins, but the pre-processor itself must be installed. For Sass that is sass-embedded or sass.
npm ls sass sass-embedded2Fix
Install one of them as a dev dependency. Vite uses sass-embedded when it is present and falls back to sass; the docs recommend sass-embedded for speed.
npm add -D sass-embedded3Verify
Restart the dev server or run the build, and open a page that imports the .scss file.
npm run buildConfirmed by vite.dev
Cause 2 of 2
The build install leaves out devDependencies
1Check
npm omits dev dependencies by default when NODE_ENV is production, and sass was added with -D.
grep -n -B1 -A3 devDependencies package.json
echo "$NODE_ENV"2Fix
Run the install for the build stage with dev dependencies included, then prune or copy only the build output into the final image.
npm ci --include=dev
npm run build3Verify
The build step prints the finished bundle list instead of the sass error.
npm run buildConfirmed by docs.npmjs.com
How do I stop it coming back?
- Add the Sass compiler as soon as the first .scss file is added to the project.
- Run the same install and build commands in CI that you run locally, with dev dependencies included.
- In monorepos, install the compiler in the package that owns vite.config, not in the repository root only.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- Dispatch ProA real-time logistics platform: Flutter apps, Spring Boot services and a Kafka event pipeline on AWS.
- WorkforceA field app, an admin console and a self-hosted Node.js server for push and reconciliation.
Related fixes
Web apps
Playwright cannot open a headed browser on a Linux server or in Docker
npx playwright test --headed shows no window on a Linux server
A headed browser needs a display, and a Linux server or container has none.
3 causes, each with a fixWeb apps
React dev server in Docker does not reload when you save a file
Changes appear only after docker compose restart or a rebuild
File-change events often do not cross from your host into a container, so the dev server never notices the edit.
3 causes, each with a fixWeb apps
npm install fails with 'sh: node-gyp-build: command not found'
npm error command failed
A package's install script calls node-gyp-build by name.
2 causes, each with a fixWeb apps
T3 Env stops the build with Invalid environment variables
Error: Invalid environment variables
T3 Env validates process.env against your Zod schema when the app starts or builds, and stops on the first failure.
4 causes, each with a fixWeb apps
vite build cannot find index.html, especially inside Docker
Could not resolve entry module (index.html)
Vite treats index.html as the entry of the app and looks for it in the project root, which is the folder where you run the command.
4 causes, each with a fixWeb apps
Vite environment variables are undefined inside a Docker container
VITE_ variable shows undefined in the browser console
Vite replaces import.meta.env values while it builds, not when the container starts.
3 causes, each with a fix