Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run sass-convert in a node express service #24

Open
andersonbalves opened this issue Jun 4, 2020 · 2 comments
Open

Run sass-convert in a node express service #24

andersonbalves opened this issue Jun 4, 2020 · 2 comments

Comments

@andersonbalves
Copy link

andersonbalves commented Jun 4, 2020

Hi guys!

Is there a way to run this lib in a express service?

I have to do a service to convert css codes to sass codes.
I tried do make this but when I call the convert({from: 'css', to: 'sass'}) I get this following error:

events.js:187
      throw er; // Unhandled 'error' event
      ^
Error: spawn sass-convert ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:264:19)
    at onErrorNT (internal/child_process.js:456:16)
    at processTicksAndRejections (internal/process/task_queues.js:80:21)
Emitted 'error' event on ChildProcess instance at:
    at Process.ChildProcess._handle.onexit (internal/child_process.js:270:12)
    at onErrorNT (internal/child_process.js:456:16)
    at processTicksAndRejections (internal/process/task_queues.js:80:21) {
  errno: 'ENOENT',
  code: 'ENOENT',
  syscall: 'spawn sass-convert',
  path: 'sass-convert',
  spawnargs: [ '--from=css', '--to=sass', '--stdin', '--no-cache' ]
}

My code:

app.post(["/v1/css-to-sass/"], (req, res) => {
   var inputStreamReq;

   req.pipe(req.busboy);
   req.busboy.on('file', function (fieldname, file, filename) {
     console.log("Uploading: " + filename);
     const name = uuidv1();
     inputStreamReq = fs.createWriteStream(__dirname + '/../model/' + name + '.css');
     file.pipe(inputStreamReq);

     inputStreamReq.on('close', () => {
       vfs.src(__dirname + '/../model/' + name + '.css')
         .pipe(converter({
           from: 'css',
           to: 'sass'
         }))
         .pipe(vfs.src(__dirname + '/../model/'));

       res.send('');

     });
   });
@pascalduez
Copy link
Member

Hi @andersonbalves,

our sass-convert package is buggy and unmaintained. I would recommend not using it.
It's trying to access the old Ruby Sass binary, which leads to several issues.

@andersonbalves
Copy link
Author

Thanks for the answer @pascalduez

So I'll try do use ruby-sass directly (hope it works hahaha).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants