Sass lookup includes node_modules by default
See original GitHub issueDescribe the bug
When importing a sass file, either via @import
or the new @use
, lookup is done first in all of node modules, then according to SASS_PATH
specified in a .env
. This contradicts the documentation that states that to enable node_modules
lookup without prefixing with ~
, it should be explicitly added to SASS_PATH
. This is an issue if a package name (apparently at any level of the dependencies hierarchy) clashes with the name you are trying to import.
Did you try recovering your dependencies?
I tried with a new project (attached below is a sample project)
Which terms did you search for in User Guide?
Searched for: sass, sass_path, node_modules lookup
Environment
Environment Info:
System:
OS: macOS 10.15.1
CPU: (6) x64 Intel(R) Core(TM) i5-9600K CPU @ 3.70GHz
Binaries:
Node: 13.0.1 - /usr/local/bin/node
Yarn: 1.19.2 - /usr/local/bin/yarn
npm: 6.13.1 - /usr/local/bin/npm
Browsers:
Chrome: 79.0.3945.79
Firefox: 70.0.1
Safari: 13.0.3
npmPackages:
react: ^16.12.0 => 16.12.0
react-dom: ^16.12.0 => 16.12.0
react-scripts: 3.3.0 => 3.3.0
npmGlobalPackages:
create-react-app: Not Found
Steps to reproduce
- set a SASS_PATH alias to allow a shorthand absolute import
- ensure you have an npm dependency with the same name as the file you’re trying to import
- import the file
Expected behavior
The import resolves to my sass file
Actual behavior
SassError: Can't find stylesheet to import.
Reproducible demo
Attached is a sample project that reproduces the issue
- sets
SASS_PATH=src/styles
in.env
- has the
colors
npm package installed - tries to import a file named “colors.scss”
- won’t build
Issue Analytics
- State:
- Created 4 years ago
- Comments:7
Top Results From Across the Web
Importing Sass through npm - node.js - Stack Overflow
Is there a way in Sass that we can search up until we find node_modules? Or even a proper way of including Sass...
Read more >Built-In Modules - Sass
Sass provides many built-in modules which contain useful functions (and the ... The sass:map module makes it possible to look up the value...
Read more >sass-lookup - npm
This module replaces the Sass compiler's lookup algorithm for resolving a partial's path. Handles underscored/non-underscored partials, ...
Read more >Introducing Sass Modules - CSS-Tricks
Internal Sass features have also moved into the module system, so we have complete control over the global namespace. There are several built-in ......
Read more >CSS, SCSS, and Less support in Visual Studio Code
Note: You can disable VS Code's default CSS, Sass or Less validation by setting ... The Node Package Manager (npm) is included in...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
does adding a new comment count as activity? 😕
bump