TypeError: options argument must be an object
DevinCarl opened this issue · comments
var unoconv = require('unoconv');
unoconv.convert('1.docx', 'pdf', function (err, result) {
// result is returned as a Buffer
fs.writeFile('converted.pdf', result);
});
below error:
child_process.js:961
throw new TypeError('options argument must be an object');
^
TypeError: options argument must be an object
at normalizeSpawnArguments (child_process.js:961:11)
at Object.exports.spawn (child_process.js:984:38)
at Object.unoconv.convert (E:\Projects\node_modules\unoconv\index.js:46:26)
at Object. (E:\Projects\01_Tmp\hwcloud\test.js:15:9)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
at startup (node.js:129:16)
The issue is with childProcess.spawn. Using node 0.10.36 should fix your issue. If you can't use an older version try using childProcess.exec(bin, function (err, stdout, stderr) { });
It seems like .spawn has changed slightly and no longer has the option for a callback. if you remove the callback function from the unoconv.convert function so it looks something like this:
child = childProcess.spawn(bin, args);
child.stdout.on('data', function (data) {
stdout.push(data);
});
child.stderr.on('data', function (data) {
stderr.push(data);
});
child.on('exit', function () {
if (stderr.length) {
return callback(new Error(Buffer.concat(stderr).toString()));
}
It worked for me!
aeastes is correct. I created a new version of this library a few days ago that uses the new version of childProcess.spawn. You can check it out here: https://github.com/HAASLEWER/unoconv2 and https://www.npmjs.com/package/unoconv2 on npm.
hello !!
result is returned as a Buffer
fs.writeFile('converted.pdf', result); result is undefined
can you help solution this bug