Cannot Set Property 'exports' Of Undefined
I have absolutely no clue why node.js makes including files from other files so difficult. I have a file called file_handler.js exports = {}; exports = { upload_file: function
Solution 1:
Okay, apparently it's because I need to load it as an AMD module.
module.exports = {...} is the CommonJS way.
define(function() {...}); is the AMD way (which I needed to use).
Solution 2:
It should be:
module.exports = {
upload_file: function (fileUploaderPath, filename) {
var child_process = require('intern/dojo/node!child_process');
child_process.spawn(fileUploaderPath + ' ' + filename);
}
};
I have just tried this and it worked.
Alternatively, you can do something like this:
exports.upload_file=function (fileUploaderPath, filename) {
var child_process = require('intern/dojo/node!child_process');
child_process.spawn(fileUploaderPath + ' ' + filename);
};
Post a Comment for "Cannot Set Property 'exports' Of Undefined"