Can't find stylesheet to import error during site build with eleventy

Eleventy site builds fine locally but the Netlify build fails when Sass tries to import Bootstrap stylesheets in app.scss. Multiple import syntaxes were tried (with tilde, without nodemodules path, with nodemodules path). For example, "../nodemodules/bootstrap/scss/functions" works locally but errors the same on the Netlify build. The build log shows the failure: "Can't find stylesheet to import" at line 7, @import "../../../bootstrap/scss/_variables" in ./src/assets/sass/app.scss, via TemplateContentRenderError / TemplateContentCompileError. The build uses pnpm (sass@1.101.0 visible in the stack trace).

looks like the import path is relative to the scss file itself, not the repo root. from src/assets/sass/app.scss, ../../../bootstrap/scss/variables resolves to /bootstrap/scss/variables, and nodemodules isnt in that path at all, so sass cant find it anywhere. ../nodemodules/… has the same problem: from that folder it points at src/assets/node_modules, which doesnt exist.

guessing your local machine has something slightly different going on (stale build output, a different entry point, whatever), but id stop chasing that and just fix the import instead.

import it as "bootstrap/scss/functions" and add nodemodules to the sass load paths in your eleventy config. that way it resolves the same on your machine and on netlify. also double check bootstrap is actually listed in dependencies in package.json, since the build log shows pnpm and pnpm wont hoist it to the top level of nodemodules unless its a direct dep.

Source: https://answers.netlify.com/t/cant-find-stylesheet-to-import-error-during-site-build-with-eleventy/166264