Stencil CLI + SASS partial引入报错:文件不存在,跨系统兼容问题求助
Hey there, this cross-platform issue (working on Mac but failing on Windows) almost always boils down to filesystem case sensitivity differences or Windows-specific path parsing quirks with Stencil CLI. Let’s walk through the most likely fixes:
1. Double-check filename/path case consistency
Mac’s default filesystems (APFS/HFS+) are case-insensitive, so your colleague’s Mac can resolve ./layout/_pdp.scss even if the actual file is named _PDP.scss or _PdP.scss. But Windows’ NTFS is case-sensitive by default (and Stencil CLI’s parser tends to respect that strictly):
- Navigate to your project’s
layoutfolder and verify the exact filename matches what’s in your import statement—including the leading underscore and lowercasepdp. - If there’s any case mismatch, rename the file to exactly match your import (e.g., if your import uses
_pdp.scss, make sure the file isn’t_PDP.scss).
2. Tweak your SASS import syntax for Windows compatibility
Stencil CLI can handle path parsing differently on Windows, so try these adjustments to your import line:
- Stick with forward slashes (
/) as path separators—never use Windows-style backslashes (\). For example, use@import './layout/_pdp.scss';instead of.\\layout\\_pdp.scss. - Leverage SASS’s default partial rules: omit the leading underscore and file extension, so write
@import './layout/pdp';—SASS will automatically look for_pdp.scss.
3. Clear Stencil’s cache and restart the service
Cached path data can sometimes cause weird resolution issues. Here’s how to reset it:
- Stop your running
stencil startprocess withCtrl+C. - Delete Stencil’s cache folder on Windows: paste
%LOCALAPPDATA%\stencil-cliinto File Explorer’s address bar, then delete all contents inside. - Restart the service with
stencil startand test your local site again.
4. Enable case sensitivity for your project directory (Windows-specific)
If your Windows setup has case-insensitivity enabled for the drive (some newer Windows versions allow this), it might conflict with Stencil’s parsing. Fix it with this command:
- Open Command Prompt, navigate to your project’s root directory.
- Run
fsutil file setcasesensitiveinfo . enableto turn on case sensitivity for the project folder. - Restart
stencil startand check if the error is gone.
If none of these work, sharing the exact SCSS import line that’s throwing the error would help narrow things down further. But given the cross-platform behavior you’re seeing, the first two fixes should resolve the issue for most cases.
内容的提问来源于stack exchange,提问作者Tyler V.

