Sorry to bother you again Giuseppe. Perhaps this is one for Stack Overflow: Why would define still be undefined after requiring lightstreamer_node.js in the way you described above? From what I have read here: http://requirejs.org/docs/node.html requirejs should define define for me.
I have installed requirejs
Code:
npm install requirejs
and my code looks like this
Code:
var ls = {};
IGInterface.prototype.connectToLightstreamer = function(loginCallback) {
var requirejs;
requirejs = require('requirejs');
requirejs.config({
deps: ["../thirdparty/lightstreamer_node.js"],
nodeRequire: require
});
return requirejs(["LightstreamerClient", "Subscription"], (function(_this) {
return function(LightstreamerClient, Subscription) {
ls.LightstreamerClient = LightstreamerClient;
ls.Subscription = Subscription;
_this.lsClient = new ls.LightstreamerClient(_this.endPoint);
_this.lsClient.connectionDetails.setUser(_this.clientId);
_this.lsClient.connectionDetails.setPassword(_this.getPassword());
_this.lsClient.addListener({
onStatusChange: function(status) {
_this.showMessage("LS connection status: " + status);
if (status === "CONNECTED:WS-STREAMING") {
return loginCallback();
}
}
});
return _this.lsClient.connect();
};
})(this));
};
the error is
Code:
/home/ubuntu/workspace/node_modules/requirejs/bin/r.js:2585
throw err;
^
Error: Tried loading "../thirdparty/lightstreamer_node.js" at ../thirdparty/lightstreamer_node.js then tried node's require("../thirdparty/lightstreamer_node.js") and it failed with error: ReferenceError: define is not defined
at /home/ubuntu/workspace/node_modules/requirejs/bin/r.js:2578:27
at Object.context.execCb (/home/ubuntu/workspace/node_modules/requirejs/bin/r.js:1929:33)
at Object.Module.check (/home/ubuntu/workspace/node_modules/requirejs/bin/r.js:1129:51)
at Object.Module.enable (/home/ubuntu/workspace/node_modules/requirejs/bin/r.js:1416:22)
at Object.Module.init (/home/ubuntu/workspace/node_modules/requirejs/bin/r.js:1034:26)
at callGetModule (/home/ubuntu/workspace/node_modules/requirejs/bin/r.js:1443:63)
at Object.context.completeLoad (/home/ubuntu/workspace/node_modules/requirejs/bin/r.js:1822:21)
at Function.req.load (/home/ubuntu/workspace/node_modules/requirejs/bin/r.js:2591:17)
at Object.context.load (/home/ubuntu/workspace/node_modules/requirejs/bin/r.js:1918:21)
at Object.Module.load (/home/ubuntu/workspace/node_modules/requirejs/bin/r.js:1080:29)
I have tried reinstalling requirejs several times, deleting it in node_modules first and I've also re downloaded lightstreamer_node.js to make sure it's not been corrupted by me. Any ideas?
Cheers,
Tim
Bookmarks