I've tried to add the module in the thethingsbox.js, to get it globally avaible but when I add it the Thethingbox won't start after restarting.
Also it installs the npm package, but when it try it in a simple function node with only:
var TelldusAPI = require('telldus-live');
return msg;
the debug window says:
ReferenceError: require is not defined (line 1, col 18)
I changed in the thethingbox.js
var http = require('http');
var express = require("express");
var RED = require("node-red");
var settings = require('./settingsttb');
var PORT = 1880;
// Create an Express app
var app = express();
// Add a simple route for static content served from 'public'
app.use("/", express.static("public"));
app.use(express.favicon(__dirname + '/node_modules/node-red/public/favicon.ico'));
// Create a server
var server = http.createServer(app);
var settings_ttb = settings.loadSettings();
// console.log("Settings TTB:" + JSON.stringify(settings_ttb));
// Create the settings object
var userDir="/root/userdir/";
var flowDir=userDir;
var settings_nodered = { // http://nodered.org/docs/configuration.html
httpAdminRoot:"/",
httpNodeRoot: "/api/",
userDir: userDir,
flowDir: flowDir, // TTB specific
flowFile: flowDir + "flows.json",
verbose: true,
flowFilePretty: true,
paletteCategories:['subflows', 'input', 'output', 'function', 'social', 'storage', 'analysis', 'advanced'],
hiddenWorkspaces: [ ],
functionGlobalContext: {
settings: settings_ttb
,userDir: userDir
,wpi: require('node-red/node_modules/wiring-pi') // https://www.npmjs.com/package/wiring-pi
,CryptoJS: require('node-red/node_modules/crypto-js') // https://www.npmjs.com/package/cryptojs
,HID: require('node-red/node_modules/node-hid') // https://www.npmjs.com/package/node-hid
,TelldusAPI: require('~/thethingbox/node_modules/telldus-live')
}
};
// Initialise the runtime with a server and settings
RED.init(server,settings_nodered);
// Serve the editor UI from /
app.use(settings_nodered.httpAdminRoot,RED.httpAdmin);
// Serve the http nodes UI from /api
app.use(settings_nodered.httpNodeRoot,RED.httpNode);
server.listen(PORT);
//Start the runtime
RED.start();
I've tried to add the module in the thethingsbox.js, to get it globally avaible but when I add it the Thethingbox won't start after restarting. Also it installs the npm package, but when it try it in a simple function node with only:
the debug window says:
ReferenceError: require is not defined (line 1, col 18)
I changed in the
thethingbox.js