question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Sass lookup includes node_modules by default

See original GitHub issue

Describe 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

  1. set a SASS_PATH alias to allow a shorthand absolute import
  2. ensure you have an npm dependency with the same name as the file you’re trying to import
  3. import the file

Expected behavior

The import resolves to my sass file

Actual behavior

SassError: Can't find stylesheet to import.

Schermata 2019-12-17 alle 13 15 52

Reproducible demo

sass-import-bug.zip

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:closed
  • Created 4 years ago
  • Comments:7

github_iconTop GitHub Comments

2reactions
agoscommented, Jan 16, 2020

does adding a new comment count as activity? 😕

0reactions
paulhan221commented, Mar 24, 2020

bump

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found