Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

@import fails in node-sass 0.2.4 #27

Closed
William-Owen opened this issue Oct 2, 2012 · 37 comments
Closed

@import fails in node-sass 0.2.4 #27

William-Owen opened this issue Oct 2, 2012 · 37 comments

Comments

@William-Owen
Copy link

When attempting to use a simple @import I get the following error message: -

ERROR -- , line 1: error reading file "variables"

My app config: -

app.configure(function(){

    app.set('views', __dirname + '/buildkit/views');
    app.set('view engine', 'jade');
    app.set('view options', {pretty: true});
    app.use(express.favicon());
    app.use(express.logger('dev'));
    app.use(express.bodyParser());
    app.use(express.methodOverride());
    app.locals.pretty = true;
    app.use(sass.middleware({
        "src" : __dirname + '/buildkit/assets/sass',
        "dest" : __dirname + '/buildkit/assets/',
        "debug" : true
    }));
    app.use(express.static(__dirname + '/buildkit/assets'));

});

My SASS 'screen.scss' (in the same directory as '_variables.scss': -

@import "variables";

body {
    background:red;
}

I have also tried importing '_variables.scss'

Any thoughts / help welcome.

@AdamPflug
Copy link

+1 for this issue, can't figure out what's causing it.

My example

var sassOptions = {
    include_paths: [options.baseUrl]
};
if (options.minify) {
    sassOptions.output_style = 'compressed';
}
sass.render(css, function(err, output){
    if (err) fail(err);
    compiledCSS = output;
    console.log("Done!");
    fs.writeFile(outputFile, compiledCSS, done);
}, sassOptions);'
@import "ProductSearchView.scss";
Error: ERROR -- , line 1: error reading file "ProductSearchView.scss"

@djensen47
Copy link

This is kind of a huge issue. Any thoughts on fixing this?

@andrew
Copy link
Contributor

andrew commented Dec 9, 2012

I'll look into this as soon as I get the chance.

@farin
Copy link

farin commented Jan 4, 2013

voting for this. I just tried to use node-sass and it failed such way. It is critical bug. Without import it is unusable for real projects.

@ghost ghost assigned andrew Jan 7, 2013
@andrew
Copy link
Contributor

andrew commented Jan 7, 2013

I'm just looking into this now, I believe it's because node-sass currently uses the string context of libsass.

Once I've completed #25 it should be easy to fix.

@deanmao
Copy link
Contributor

deanmao commented Jan 7, 2013

I'll look into this as well. Thanks for the bug note!

@andrew andrew mentioned this issue Jan 7, 2013
@dmauro
Copy link

dmauro commented Jan 22, 2013

👍 Would love to see this get fixed. If I try to use any builds before 0.2.4 I get Segmentation Fault: 11 errors. I simply can't use this yet, so I'm still stuck with the Ruby Sass.

@mpalermo
Copy link

👍 I would also like to see this get fixed. manually parsing our sass files until it's fixed, hope thats soon!

@andrew
Copy link
Contributor

andrew commented Feb 3, 2013

I've just published 0.3.0 which I believe fixes this issue, can anyone else confirm?

https://npmjs.org/package/node-sass

@andrew andrew closed this as completed Feb 3, 2013
@yefremov
Copy link

yefremov commented Feb 3, 2013

Nope, still the same error.

ERROR -- , line 1: error reading file "mixins"

@andrew
Copy link
Contributor

andrew commented Feb 3, 2013

@yefremov which OS are you running on? I forgot to rebuild binaries for platforms other than mac.

@yefremov
Copy link

yefremov commented Feb 3, 2013

@andrew Windows 7

@andrew
Copy link
Contributor

andrew commented Feb 3, 2013

I don't have a Windows 7 VM to hand, can you try rebuilding it on your platform? I've added instructions to the readme: https://github.com/andrew/node-sass#rebuilding-binaries

@yefremov
Copy link

yefremov commented Feb 3, 2013

Uhh, not that easy to do it on Win:

if (process.platform === 'darwin') {
  spawn('node-gyp', ['rebuild']);
}

I'll try to dig into it tomorrow and let you know.

@andrew
Copy link
Contributor

andrew commented Feb 3, 2013

Ah, not idea. You could try:

npm install -g node-gyp
node-gyp rebuild

@andrew andrew reopened this Feb 3, 2013
@dmauro
Copy link

dmauro commented Feb 3, 2013

I'm still getting the error with 0.3.0 on OS 10.7.5

Rendering this code:

@import "mixins";

body {
    @include fullsize();
    color:white;
}

Results in the error:
:1: error: error reading file "mixins"

(mixins.scss is in the same directory as this file and I also tried it with an explicit file extension with no luck)

@noazark
Copy link

noazark commented Feb 19, 2013

Same here. OS X 10.8, using node-sass v0.3.0.

@sanchan
Copy link

sanchan commented Feb 20, 2013

Same as @noazark but Archlinux

@andrew
Copy link
Contributor

andrew commented Mar 28, 2013

I've just pushed a new version, can you give it a try with 0.4.0

@dmauro
Copy link

dmauro commented Apr 10, 2013

Still not working for me, but I'm on an older version of node and it looked like node-sass wanted >= 0.10.0

@branneman
Copy link

Not working for me on Windows 8, using node-sass 0.4.0.

@branneman
Copy link

I found a workaround for my situation, maybe it can be of help for others with the same problem:

What I did basically is grab the raw Sass as a string, and let node-sass render that for me. Since it's current working directory is wherever your server.js file is located, you're going to have to put url's in your sass file relative to your server.js.

https://github.com/branneman/frontend-bootstrap/blob/master/server.js#L13-24
https://github.com/branneman/frontend-bootstrap/blob/master/src/static/css/all.scss

@andrew
Copy link
Contributor

andrew commented Apr 22, 2013

@branneman I've published v0.4.3 which has windows binarys for 32 and 64bit, can you give that a try?

@bwilkins
Copy link
Contributor

It seems to me that this error only occurs if the file cannot be read. The error itself is originating from within libsass.

@branneman When you use node-sass's render (or now renderSync) functionality directly, then libsass ends up getting fed a string of bytes representing the contents of the file, rather than the filename for libsass to load directly. If the base scss file (and the files it includes) is in any other directory than that which the code is being executed from, then you absolutely must pass this in to render/renderSync in the options hash as an array of paths (ie {includePaths: ['path/to/scss_folder']}}, else it will not be able to find the files you are looking for.

Unfortunately I'm not sure how this applies to the middleware version of node-sass, though it generally only comes about from not being able to locate a file.

TL;DR: use the includePaths option liberally.

@branneman
Copy link

Perfect! That solves it, you can see in this commit how my code ended up:
branneman/frontend-boilerplate@fc61b80

@andrew andrew closed this as completed Apr 23, 2013
@dfyx
Copy link

dfyx commented Sep 3, 2013

For me, this bug still appears in node-sass 0.6.4 on Windows 7 when combined with mincer and grunt.

Generating file tmp/application.css...
Warning: :6: error: error reading file "components/hidden-pin"

Here are some of the relevant files

Gruntfile.js

    // ...
    mince: {
      'application.css': {
        include: ['assets/stylesheets', 'vendor/stylesheets'],
        src: 'application.css.scss',
        dest: 'tmp/application.css'
      }
    },
    // ...

application.css.scss

//= require normalize

@import "components/hidden-pin";
@import "layouts/common";
@import "layouts/simple";
@import "layouts/full";
@import "pages/pin-input";

The same project builds just fine on Linux Mint / Ubuntu.

@billpull
Copy link

@dfyx any luck finding a workaround?

@andrew
Copy link
Contributor

andrew commented Nov 19, 2013

Is this still an issue in 0.7.0?

@dfyx
Copy link

dfyx commented Nov 20, 2013

I'll check tomorrow when I'm back at work.

@LaurentGoderre
Copy link
Contributor

@dfyx @billpull I had forgotten to fix the renderSync method. The latest PR should fix this.

@dfyx
Copy link

dfyx commented Nov 21, 2013

Okay, I'll have to wait for the next release. Compiling the whole thing from source would take a little more time than I have right now.

(If you want me to test it earlier, please send me a precompiled version for 32 bit Windows)

@LaurentGoderre
Copy link
Contributor

@dfyx the compiled code didn't change, only the javascript file

@dfyx
Copy link

dfyx commented Nov 21, 2013

I'll try again tomorrow.

@dfyx
Copy link

dfyx commented Jan 20, 2014

Alright, took a little longer than expected (honestly I just forgot to check).

The problem still exists with node-sass 0.8.1 but the error message is slightly different:

Generating file tmp/application.css...
Warning: source string:6: error: file to import not found or unreadable: "components/hidden-pin"

@dfyx
Copy link

dfyx commented Jan 20, 2014

Okay, update: fixed by installing a newer version of grunt-mincer.

@parag
Copy link

parag commented Jun 7, 2015

Was having the same issue. It got fixed by changing
@import 'mixin'
to
@import 'mixin.scss.css'

Should not have fixed like this though.

@xzyfer
Copy link
Contributor

xzyfer commented Jun 9, 2015

Are you sure you're using 0.2.4? That's an incredible old and unsupported
version.

Please update to 3.1.
On 7 Jun 2015 09:35, "Parag Arora" notifications@github.com wrote:

Was having the same issue. It got fixed by changing
@import https://github.com/import 'mixin'
to
@import https://github.com/import 'mixin.scss.css'

Should not have fixed like this though.


Reply to this email directly or view it on GitHub
#27 (comment).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests