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.

"File to import not found or unreadable" When @import scss file from node_modules

See original GitHub issue

Not sure if it is an actual bug or my curly hands, but i tried to provide as more details as possible to help solve this problem.

Is this a bug report?

Yes

Can you also reproduce the problem with npm 4.x?

Yes

Environment

  1. node -v: 6.9.5
  2. npm -v:4.6.1
  3. npm ls react-scripts (if you haven’t ejected): react-scripts@1.0.10

Then, specify:

  1. Operating system: Windows 10

Steps to Reproduce

(Write your steps here:)

  1. create-react-app test && cd test
  2. Make changes according to scss section
  3. npm install react-select (actually any module with scss files should reproduce)
  4. add @import "~react-select\scss\default.scss && npm start
  5. see build error: { "status": 1, "file": "{my local path here}/test/src/App.scss", "line": 1, "column": 1, "message": "File to import not found or unreadable: ~react-select/scss/default.\nParent style sheet: {my local path here}//test/src/App.scss", "formatted": "Error: File to import not found or unreadable: ~react-select/scss/default.\n Parent style sheet: {my local path here}/test/src/App.scss\n on line 1 of src/App.scss\n>> @import \"~react-select/scss/default\";\ n ^\n" }

Expected Behavior

Just normal scss compile, coz it OK works for files not from node modules. BTW importing css works fine from node_modules

Actual Behavior

{ "status": 1, "file": "{my local path here}/test/src/App.scss", "line": 1, "column": 1, "message": "File to import not found or unreadable: ~react-select/scss/default.\nParent style sheet: {my local path here}//test/src/App.scss", "formatted": "Error: File to import not found or unreadable: ~react-select/scss/default.\n Parent style sheet: {my local path here}/test/src/App.scss\n on line 1 of src/App.scss\n>> @import \"~react-select/scss/default\";\ n ^\n" }

Reproducible Demo

https://github.com/vynogradskyi/cra_bug

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

22reactions
gaearoncommented, Jul 26, 2017

Is it a bug though? The ~ notation is webpack-specific. If I understand correctly, when Sass is precompiled by its own CLI, it processes @imports by itself, and thus doesn’t understand ~ notation. I think if you replaced this with node_modules/ instead it might work.

12reactions
bochen2014commented, Jan 19, 2018

in your webpack.config.js file, add

 { 
     module:{
            rules: [
                { test : /\.scss$/,
                  uese: {
                        loader: 'sass-loader',
                       options: {
                           includePaths: [
                                 path.resolve('../node_modules'), // @import('jeet/scss/jeet/index')
                   ...
               ]
             }
}

so that you don’t have to put node_modules in your code

Read more comments on GitHub >

github_iconTop Results From Across the Web

SCSS file error: File to import not found or unreadable: bootstrap
It's looking for a file called default.scss and is unable to do so. Make sure the file exists in the sass_dir you configured...
Read more >
Error: File to import not found or unreadable: bootstrap - Drupal
Installed bootstrap in my custom theme. From my custom theme directory, ran npm install bootstrap . This created the "node_modules" folder. I ...
Read more >
Question: npm run compile:scss throwing error
File to import not found or unreadable : variables. in C:\Users\sharm\Documents\cpf-sfcc\cpf-brands\cartridges\app_custom_cpfbrands\cartridge\ ...
Read more >
File to import not found or unreadable - Laracasts
Ran composer update, composer dump-autoload, and npm install · The 'main-site' folder is inside the same folder as my app.scss folder · My...
Read more >
sass/node-sass - Gitter
"message": "File to import not found or unreadable: ./_Foo.",. @import "./_Foo";. "node-sass": "^4.11.0",. I have a folder called _Foo and an _index.scss ......
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