Create-react-app: Sass lookup includes node_modules by default

Created on 17 Dec 2019  路  7Comments  路  Source: facebook/create-react-app

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
bug report needs triage stale

All 7 comments

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

does adding a new comment count as activity? 馃槙

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

I wonder if this issue will ever be triaged!

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

This issue has been automatically closed because it has not had any recent activity. If you have a question or comment, please open a new issue.

bump

Was this page helpful?
0 / 5 - 0 ratings

Related issues

oltsa picture oltsa  路  3Comments

AlexeyRyashencev picture AlexeyRyashencev  路  3Comments

jnachtigall picture jnachtigall  路  3Comments

adrice727 picture adrice727  路  3Comments

dualcnhq picture dualcnhq  路  3Comments