How to access node-sass regression (?) "It is unclear which file to import for @import"

The latest version of node-sass (3.4.1) seems to break our assembly. I keep getting this error message:

 It not clear which file to import for '@import "../file"'. Candidates: ../file.scss ../file.css Please delete or rename all but one of these files. 

Now this happens for all files in the project that do not explicitly specify "file.scss" in their name.

I could not determine the fix for this error. Also, I can not find the documentation to solve what has changed in node-sass to call it. We have too many files to make it convenient to rename each import.

Can someone point me in the right direction?

Edit:

This also happens with files that have underscores (like _file ) in their path. It seems that they do not recognize that these files are partial.

+5
source share
2 answers

I had the same problem, but only with node-sass version 3.4.2. Version 3.4.1 worked fine for me.

This seems to be a known issue in node-sass - https://github.com/sass/node-sass/issues/1222 , however it is not clear which versions are affected.

I fixed it by removing grunt-sass , and then installing the exact version of node-sass that worked correctly (v3.4.1), and then finally reinstalling grunt-sass .

 $ npm uninstall grunt-sass $ npm install node-sass@3.4.1 --save-dev $ npm install grunt-sass 

This means that grunt-sass uses your installed version, rather than installing its own version, which it defines as "node-sass": "^3.4.0"

Strange, although I indicated the exact version in the installation command, I still ended up with this in my package. json:

 "node-sass": "^3.4.1" 

So, I manually changed this to the exact version so that other developers on the team get the correct version:

 "node-sass": "3.4.1" 

Of course, if you find that the only version that works for you is v3.3.0, then use this version in the instructions above.

+7
source

Option 1

You can import using the file extension

 @import "../file.scss" 

Option 2

Or you can tell SASS not to generate the .css file by importing without output. You must rename the file from file.scss to _file.scss

This will allow you to import like this.

 @import "../file" 

I prefer option 2, as it reduces the number of css files you should keep track of.

+7
source

Source: https://habr.com/ru/post/1235555/


All Articles