Run sass-convert in a node express service
andersonbalves opened this issue · comments
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('');
});
});
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.
Thanks for the answer @pascalduez
So I'll try do use ruby-sass directly (hope it works hahaha).