node-unoconv
node-unoconv copied to clipboard
TypeError: options argument must be an object
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.
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