简体   繁体   中英

Why can't Sass see my .scss file in an Express app?

I'm building an Express app with Sass and I haven't made ANY changes to my project since I last compiled my .scss and .css files.

The command:

sass sass/style.scss style.css

was working the last time I worked on my project, but today I'm getting this error:

Errno::ENOENT: No such file or directory @ rb_sysopen - sass/style.scss
  Use --trace for backtrace.

Again, I've made NO NEW changes since this was last working, and I've even reverted to a previous git commit.

In my app.js, I have node-sass-middleware configured like this:

var sassMiddleware = require('node-sass-middleware');

and this:

app.use(sassMiddleware({
  src: path.join(__dirname, 'public/stylesheets/sass'),
  dest: path.join(__dirname, 'public/stylesheets'),
  debug: true,
  indentedSyntax: true,
  outputStyle: 'compressed',
  prefix: '/stylesheets'
}));
app.use(express.static(path.join(__dirname, 'public')));

and my public file structure in My-Website/public looks like this:

├── public
    └── stylesheets
        ├── sass
            └── style.scss
        ├── style.css
        └── style.css.map

Also, in my layout.hbs file in my views folder (I'm using the handlebars templating language for Express), I have this link in my head:

    <link rel='stylesheet' href='/stylesheets/style.css' />

What is going on?

You have multiple components going on here, the command sass and node-sass-middleware, which uses the sass command to compile the sheets. In the beginning of the post you reference the sass command not working, and then you transition into your express script, which I assume means it also doesn't work. Check your current working directory, and ensure that it's public/stylesheets/ when you run the first command

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM