Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

does not work #10

Open
bife34 opened this issue Dec 2, 2018 · 2 comments
Open

does not work #10

bife34 opened this issue Dec 2, 2018 · 2 comments

Comments

@bife34
Copy link

bife34 commented Dec 2, 2018

hi people...i install the module and make the config like any other, but it makes my screen black, how can i solve it.. can someone explain me. ty

@DNA2010
Copy link

DNA2010 commented Apr 15, 2019

reinstall software till a black screen, raspberry pi 3 B+, looks like the program is in a loop,
new to javascript programming
here is the output of the program

pi@raspberrypi:~/MagicMirror $ npm start

[email protected] start /home/pi/MagicMirror
sh run-start.sh

Starting MagicMirror: v2.7.1
Loading config ...
Loading module helpers ...
No helper found for module: alert.
Initializing new module helper ...
Module helper loaded: updatenotification
No helper found for module: clock.
Initializing new module helper ...
Module helper loaded: calendar
No helper found for module: compliments.
No helper found for module: currentweather.
No helper found for module: weatherforecast.
Initializing new module helper ...
Module helper loaded: newsfeed
Initializing mm-music-player module helper ...
init function started - A
======================= Class ==================================
{ [Function] extend: [Function] }
======================= express ==================================
{ [Function: createApplication]
application:
{ init: [Function: init],
defaultConfiguration: [Function: defaultConfiguration],
lazyrouter: [Function: lazyrouter],
handle: [Function: handle],
use: [Function: use],
route: [Function: route],
engine: [Function: engine],
param: [Function: param],
set: [Function: set],
path: [Function: path],
enabled: [Function: enabled],
disabled: [Function: disabled],
enable: [Function: enable],
disable: [Function: disable],
acl: [Function],
bind: [Function],
checkout: [Function],
connect: [Function],
copy: [Function],
delete: [Function],
get: [Function],
head: [Function],
link: [Function],
lock: [Function],
'm-search': [Function],
merge: [Function],
mkactivity: [Function],
mkcalendar: [Function],
mkcol: [Function],
move: [Function],
notify: [Function],
options: [Function],
patch: [Function],
post: [Function],
propfind: [Function],
proppatch: [Function],
purge: [Function],
put: [Function],
rebind: [Function],
report: [Function],
search: [Function],
source: [Function],
subscribe: [Function],
trace: [Function],
unbind: [Function],
unlink: [Function],
unlock: [Function],
unsubscribe: [Function],
all: [Function: all],
del: [Function],
render: [Function: render],
listen: [Function: listen] },
request:
IncomingMessage {
header: [Function: header],
get: [Function: header],
accepts: [Function],
acceptsEncodings: [Function],
acceptsEncoding: [Function],
acceptsCharsets: [Function],
acceptsCharset: [Function],
acceptsLanguages: [Function],
acceptsLanguage: [Function],
range: [Function: range],
param: [Function: param],
is: [Function: is],
protocol: [Getter],
secure: [Getter],
ip: [Getter],
ips: [Getter],
subdomains: [Getter],
path: [Getter],
hostname: [Getter],
host: [Getter],
fresh: [Getter],
stale: [Getter],
xhr: [Getter] },
response:
ServerResponse {
status: [Function: status],
links: [Function],
send: [Function: send],
json: [Function: json],
jsonp: [Function: jsonp],
sendStatus: [Function: sendStatus],
sendFile: [Function: sendFile],
sendfile: [Function],
download: [Function: download],
type: [Function: contentType],
contentType: [Function: contentType],
format: [Function],
attachment: [Function: attachment],
append: [Function: append],
header: [Function: header],
set: [Function: header],
get: [Function],
clearCookie: [Function: clearCookie],
cookie: [Function],
location: [Function: location],
redirect: [Function: redirect],
vary: [Function],
render: [Function: render] },
Route: [Function: Route],
Router:
{ [Function]
param: [Function: param],
handle: [Function: handle],
process_params: [Function: process_params],
use: [Function: use],
route: [Function: route],
acl: [Function],
bind: [Function],
checkout: [Function],
connect: [Function],
copy: [Function],
delete: [Function],
get: [Function],
head: [Function],
link: [Function],
lock: [Function],
'm-search': [Function],
merge: [Function],
mkactivity: [Function],
mkcalendar: [Function],
mkcol: [Function],
move: [Function],
notify: [Function],
options: [Function],
patch: [Function],
post: [Function],
propfind: [Function],
proppatch: [Function],
purge: [Function],
put: [Function],
rebind: [Function],
report: [Function],
search: [Function],
source: [Function],
subscribe: [Function],
trace: [Function],
unbind: [Function],
unlink: [Function],
unlock: [Function],
unsubscribe: [Function],
all: [Function] },
json: [Function: json],
query: [Function: query],
static:
{ [Function: serveStatic]
mime:
Mime {
types: [Object],
extensions: [Object],
default_type: 'application/octet-stream',
Mime: [Function: Mime],
charsets: [Object] } },
urlencoded: [Function: urlencoded] }
======================== path =================================
{ resolve: [Function: resolve],
normalize: [Function: normalize],
isAbsolute: [Function: isAbsolute],
join: [Function: join],
relative: [Function: relative],
toNamespacedPath: [Function: toNamespacedPath],
dirname: [Function: dirname],
basename: [Function: basename],
extname: [Function: extname],
format: [Function: format],
parse: [Function: parse],
sep: '/',
delimiter: ':',
win32:
{ resolve: [Function: resolve],
normalize: [Function: normalize],
isAbsolute: [Function: isAbsolute],
join: [Function: join],
relative: [Function: relative],
toNamespacedPath: [Function: toNamespacedPath],
dirname: [Function: dirname],
basename: [Function: basename],
extname: [Function: extname],
format: [Function: format],
parse: [Function: parse],
sep: '\',
delimiter: ';',
win32: [Circular],
posix: [Circular],
_makeLong: [Function: toNamespacedPath] },
posix: [Circular],
_makeLong: [Function: toNamespacedPath] }

setname function started - C
mm-music-player
========== this.name========================================
setpath function started - D
/home/pi/MagicMirror/modules/mm-music-player
========== this path =========================================
WARNING! Could not load config file. Starting with default configuration. Error found: TypeError: m.loaded is not a function
Loading module helpers ...
No helper found for module: alert.
Initializing new module helper ...
Module helper loaded: updatenotification
No helper found for module: clock.
Initializing new module helper ...
Module helper loaded: calendar
No helper found for module: compliments.
No helper found for module: currentweather.
No helper found for module: weatherforecast.
Initializing new module helper ...
Module helper loaded: newsfeed
Initializing mm-music-player module helper ...
init function started - A
======================= Class ==================================
{ [Function] extend: [Function] }
======================= express ==================================
{ [Function: createApplication]
application:
{ init: [Function: init],
defaultConfiguration: [Function: defaultConfiguration],
lazyrouter: [Function: lazyrouter],
handle: [Function: handle],
use: [Function: use],
route: [Function: route],
engine: [Function: engine],
param: [Function: param],
set: [Function: set],
path: [Function: path],
enabled: [Function: enabled],
disabled: [Function: disabled],
enable: [Function: enable],
disable: [Function: disable],
acl: [Function],
bind: [Function],
checkout: [Function],
connect: [Function],
copy: [Function],
delete: [Function],
get: [Function],
head: [Function],
link: [Function],
lock: [Function],
'm-search': [Function],
merge: [Function],
mkactivity: [Function],
mkcalendar: [Function],
mkcol: [Function],
move: [Function],
notify: [Function],
options: [Function],
patch: [Function],
post: [Function],
propfind: [Function],
proppatch: [Function],
purge: [Function],
put: [Function],
rebind: [Function],
report: [Function],
search: [Function],
source: [Function],
subscribe: [Function],
trace: [Function],
unbind: [Function],
unlink: [Function],
unlock: [Function],
unsubscribe: [Function],
all: [Function: all],
del: [Function],
render: [Function: render],
listen: [Function: listen] },
request:
IncomingMessage {
header: [Function: header],
get: [Function: header],
accepts: [Function],
acceptsEncodings: [Function],
acceptsEncoding: [Function],
acceptsCharsets: [Function],
acceptsCharset: [Function],
acceptsLanguages: [Function],
acceptsLanguage: [Function],
range: [Function: range],
param: [Function: param],
is: [Function: is],
protocol: [Getter],
secure: [Getter],
ip: [Getter],
ips: [Getter],
subdomains: [Getter],
path: [Getter],
hostname: [Getter],
host: [Getter],
fresh: [Getter],
stale: [Getter],
xhr: [Getter] },
response:
ServerResponse {
status: [Function: status],
links: [Function],
send: [Function: send],
json: [Function: json],
jsonp: [Function: jsonp],
sendStatus: [Function: sendStatus],
sendFile: [Function: sendFile],
sendfile: [Function],
download: [Function: download],
type: [Function: contentType],
contentType: [Function: contentType],
format: [Function],
attachment: [Function: attachment],
append: [Function: append],
header: [Function: header],
set: [Function: header],
get: [Function],
clearCookie: [Function: clearCookie],
cookie: [Function],
location: [Function: location],
redirect: [Function: redirect],
vary: [Function],
render: [Function: render] },
Route: [Function: Route],
Router:
{ [Function]
param: [Function: param],
handle: [Function: handle],
process_params: [Function: process_params],
use: [Function: use],
route: [Function: route],
acl: [Function],
bind: [Function],
checkout: [Function],
connect: [Function],
copy: [Function],
delete: [Function],
get: [Function],
head: [Function],
link: [Function],
lock: [Function],
'm-search': [Function],
merge: [Function],
mkactivity: [Function],
mkcalendar: [Function],
mkcol: [Function],
move: [Function],
notify: [Function],
options: [Function],
patch: [Function],
post: [Function],
propfind: [Function],
proppatch: [Function],
purge: [Function],
put: [Function],
rebind: [Function],
report: [Function],
search: [Function],
source: [Function],
subscribe: [Function],
trace: [Function],
unbind: [Function],
unlink: [Function],
unlock: [Function],
unsubscribe: [Function],
all: [Function] },
json: [Function: json],
query: [Function: query],
static:
{ [Function: serveStatic]
mime:
Mime {
types: [Object],
extensions: [Object],
default_type: 'application/octet-stream',
Mime: [Function: Mime],
charsets: [Object] } },
urlencoded: [Function: urlencoded] }
======================== path =================================
{ resolve: [Function: resolve],
normalize: [Function: normalize],
isAbsolute: [Function: isAbsolute],
join: [Function: join],
relative: [Function: relative],
toNamespacedPath: [Function: toNamespacedPath],
dirname: [Function: dirname],
basename: [Function: basename],
extname: [Function: extname],
format: [Function: format],
parse: [Function: parse],
sep: '/',
delimiter: ':',
win32:
{ resolve: [Function: resolve],
normalize: [Function: normalize],
isAbsolute: [Function: isAbsolute],
join: [Function: join],
relative: [Function: relative],
toNamespacedPath: [Function: toNamespacedPath],
dirname: [Function: dirname],
basename: [Function: basename],
extname: [Function: extname],
format: [Function: format],
parse: [Function: parse],
sep: '\',
delimiter: ';',
win32: [Circular],
posix: [Circular],
_makeLong: [Function: toNamespacedPath] },
posix: [Circular],
_makeLong: [Function: toNamespacedPath] }

setname function started - C
mm-music-player
========== this.name========================================
setpath function started - D
/home/pi/MagicMirror/modules/mm-music-player
========== this path =========================================
App threw an error during load
TypeError: m.loaded is not a function
at loadModule (/home/pi/MagicMirror/js/app.js:144:6)
at loadNextModule (/home/pi/MagicMirror/js/app.js:161:5)
at /home/pi/MagicMirror/js/app.js:163:6
at Class.loaded (/home/pi/MagicMirror/modules/node_modules/node_helper/index.js:19:3)
at loadModule (/home/pi/MagicMirror/js/app.js:144:6)
at loadNextModule (/home/pi/MagicMirror/js/app.js:161:5)
at /home/pi/MagicMirror/js/app.js:163:6
at loadModule (/home/pi/MagicMirror/js/app.js:146:4)
at loadNextModule (/home/pi/MagicMirror/js/app.js:161:5)
at /home/pi/MagicMirror/js/app.js:163:6
Whoops! There was an uncaught exception...
TypeError: m.loaded is not a function
at loadModule (/home/pi/MagicMirror/js/app.js:144:6)
at loadNextModule (/home/pi/MagicMirror/js/app.js:161:5)
at /home/pi/MagicMirror/js/app.js:163:6
at Class.loaded (/home/pi/MagicMirror/modules/node_modules/node_helper/index.js:19:3)
at loadModule (/home/pi/MagicMirror/js/app.js:144:6)
at loadNextModule (/home/pi/MagicMirror/js/app.js:161:5)
at /home/pi/MagicMirror/js/app.js:163:6
at loadModule (/home/pi/MagicMirror/js/app.js:146:4)
at loadNextModule (/home/pi/MagicMirror/js/app.js:161:5)
at /home/pi/MagicMirror/js/app.js:163:6
MagicMirror will not quit, but it might be a good idea to check why this happened. Maybe no internet connection?
If you think this really is an issue, please open an issue on GitHub: https://github.com/MichMich/MagicMirror/issues
Launching application.
^C
pi@raspberrypi:~/MagicMirror $

pi@raspberrypi:~/MagicMirror $ npm audit

                   === npm audit security report ===                        

┌──────────────────────────────────────────────────────────────────────────────┐
│ Manual Review │
│ Some vulnerabilities require your attention to resolve │
│ │
│ Visit https://go.npm.me/audit-guide for additional guidance │
└──────────────────────────────────────────────────────────────────────────────┘
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ High │ Arbitrary File Overwrite │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package │ tar │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in │ >=4.4.2 │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ electron-rebuild [dev] │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path │ electron-rebuild > node-gyp > tar │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info │ https://npmjs.com/advisories/803
└───────────────┴──────────────────────────────────────────────────────────────┘
found 1 high severity vulnerability in 4872 scanned packages
1 vulnerability requires manual review. See the full report for details.
pi@raspberrypi:~/MagicMirror $ npm audit fix
npm WARN [email protected] requires a peer of acorn@^6.0.0 but none is installed. You must install peer dependencies yourself.

up to date in 43.402s
fixed 0 of 1 vulnerability in 4872 scanned packages
1 vulnerability required manual review and could not be updated
pi@raspberrypi:~/MagicMirror $

@DNA2010
Copy link

DNA2010 commented Apr 16, 2019

App threw an error during load
TypeError: m.loaded is not a function
at loadModule (/home/pi/MagicMirror/js/app.js:143:6)
at loadNextModule (/home/pi/MagicMirror/js/app.js:160:5)
at /home/pi/MagicMirror/js/app.js:162:6
at Class.loaded (/home/pi/MagicMirror/modules/node_modules/node_helper/index.js:19:3)

problems in the app.js code
/* Magic Mirror

var fs = require("fs");
var Server = require(__dirname + "/server.js");
var Utils = require(__dirname + "/utils.js");
var defaultModules = require(__dirname + "/../modules/default/defaultmodules.js");
var path = require("path");

// Get version number.
global.version = JSON.parse(fs.readFileSync("package.json", "utf8")).version;
console.log("Starting MagicMirror: v" + global.version);

// global absolute root path
global.root_path = path.resolve(__dirname + "/../");

if (process.env.MM_CONFIG_FILE) {
global.configuration_file = process.env.MM_CONFIG_FILE;
}

// FIXME: Hotfix Pull Request
// MagicMirrorOrg/MagicMirror#673
if (process.env.MM_PORT) {
global.mmPort = process.env.MM_PORT;
}

// The next part is here to prevent a major exception when there
// is no internet connection. This could probable be solved better.
process.on("uncaughtException", function (err) {
console.log("Whoops! There was an uncaught exception...");
console.error(err);
console.log("MagicMirror will not quit, but it might be a good idea to check why this happened. Maybe no internet connection?");
console.log("If you think this really is an issue, please open an issue on GitHub: https://github.com/MichMich/MagicMirror/issues");
});

/* App - The core app.
*/
var App = function() {
var nodeHelpers = [];

/* loadConfig(callback)
 * Loads the config file. combines it with the defaults,
 * and runs the callback with the found config as argument.
 *
 * argument callback function - The callback function.
 */

var loadConfig = function(callback) {
	console.log("Loading config ...");
	var defaults = require(__dirname + "/defaults.js");

	// For this check proposed to TestSuite
	// https://forum.magicmirror.builders/topic/1456/test-suite-for-magicmirror/8
	var configFilename = path.resolve(global.root_path + "/config/config.js");
	if (typeof(global.configuration_file) !== "undefined") {
	    configFilename = path.resolve(global.configuration_file);
	}

	try {
		fs.accessSync(configFilename, fs.F_OK);
		var c = require(configFilename);
		checkDeprecatedOptions(c);
		var config = Object.assign(defaults, c);
		callback(config);
	} catch (e) {
		if (e.code == "ENOENT") {
			console.error(Utils.colors.error("WARNING! Could not find config file. Please create one. Starting with default configuration."));
		} else if (e instanceof ReferenceError || e instanceof SyntaxError) {
			console.error(Utils.colors.error("WARNING! Could not validate config file. Starting with default configuration. Please correct syntax errors at or above this line: " + e.stack));
		} else {
			console.error(Utils.colors.error("WARNING! Could not load config file. Starting with default configuration. Error found: " + e));
		}
		callback(defaults);
	}
};

var checkDeprecatedOptions = function(userConfig) {
	var deprecated = require(global.root_path + "/js/deprecated.js");
	var deprecatedOptions = deprecated.configs;

	var usedDeprecated = [];

	deprecatedOptions.forEach(function(option) {
		if (userConfig.hasOwnProperty(option)) {
			usedDeprecated.push(option);
		}
	});
	if (usedDeprecated.length > 0) {
		console.warn(Utils.colors.warn(
			"WARNING! Your config is using deprecated options: " +
			usedDeprecated.join(", ") +
			". Check README and CHANGELOG for more up-to-date ways of getting the same functionality.")
		);
	}
}

/* loadModule(module)
 * Loads a specific module.
 *
 * argument module string - The name of the module (including subpath).
 */
var loadModule = function(module, callback) {
	var elements = module.split("/");
	var moduleName = elements[elements.length - 1];
	var moduleFolder =  __dirname + "/../modules/" + module;

	if (defaultModules.indexOf(moduleName) !== -1) {
		moduleFolder =  __dirname + "/../modules/default/" + module;
	}

	var helperPath = moduleFolder + "/node_helper.js";

	var loadModule = true;
	try {
		fs.accessSync(helperPath, fs.R_OK);
	} catch (e) {
		loadModule = false;
		console.log("No helper found for module: " + moduleName + ".");
	}

	if (loadModule) {
		var Module = require(helperPath);
		var m = new Module();

		if (m.requiresVersion) {
			console.log("Check MagicMirror version for node helper '" + moduleName + "' - Minimum version:  " + m.requiresVersion + " - Current version: " + global.version);
			if (cmpVersions(global.version, m.requiresVersion) >= 0) {
				console.log("Version is ok!");
			} else {
				console.log("Version is incorrect. Skip module: '" + moduleName + "'");
				return;
			}
		}

		m.setName(moduleName);
		m.setPath(path.resolve(moduleFolder));
		nodeHelpers.push(m);

		m.loaded(callback);
	} else {
		callback();
	}
};

/* loadModules(modules)
 * Loads all modules.
 *
 * argument module string - The name of the module (including subpath).
 */
var loadModules = function(modules, callback) {
	console.log("Loading module helpers ...");

	var loadNextModule = function() {
		if (modules.length > 0) {
			var nextModule = modules[0];
			loadModule(nextModule, function() {
				modules = modules.slice(1);
				loadNextModule();
			});
		} else {
			// All modules are loaded
			console.log("All module helpers loaded.");
			callback();
		}
	};

	loadNextModule();
};

/* cmpVersions(a,b)
 * Compare two symantic version numbers and return the difference.
 *
 * argument a string - Version number a.
 * argument a string - Version number b.
 */
function cmpVersions(a, b) {
	var i, diff;
	var regExStrip0 = /(\.0+)+$/;
	var segmentsA = a.replace(regExStrip0, "").split(".");
	var segmentsB = b.replace(regExStrip0, "").split(".");
	var l = Math.min(segmentsA.length, segmentsB.length);

	for (i = 0; i < l; i++) {
		diff = parseInt(segmentsA[i], 10) - parseInt(segmentsB[i], 10);
		if (diff) {
			return diff;
		}
	}
	return segmentsA.length - segmentsB.length;
}

/* start(callback)
 * This methods starts the core app.
 * It loads the config, then it loads all modules.
 * When it"s done it executs the callback with the config as argument.
 *
 * argument callback function - The callback function.
 */
this.start = function(callback) {

	loadConfig(function(c) {
		config = c;

		var modules = [];

		for (var m in config.modules) {
			var module = config.modules[m];
			if (modules.indexOf(module.module) === -1 && !module.disabled) {
				modules.push(module.module);
			}
		}

		loadModules(modules, function() {
			var server = new Server(config, function(app, io) {
				console.log("Server started ...");

				for (var h in nodeHelpers) {
					var nodeHelper = nodeHelpers[h];
					nodeHelper.setExpressApp(app);
					nodeHelper.setSocketIO(io);
					nodeHelper.start();
				}

				console.log("Sockets connected & modules started ...");

				if (typeof callback === "function") {
					callback(config);
				}

			});
		});
	});
};

/* stop()
 * This methods stops the core app.
 * This calls each node_helper's STOP() function, if it exists.
 * Added to fix #1056
 */
this.stop = function() {
	for (var h in nodeHelpers) {
		var nodeHelper = nodeHelpers[h];
		if (typeof nodeHelper.stop === "function") {
			nodeHelper.stop();
		}
	}
};

/* Listen for SIGINT signal and call stop() function.
 *
 * Added to fix #1056
 * Note: this is only used if running `server-only`. Otherwise
 * this.stop() is called by app.on("before-quit"... in `electron.js`
 */
process.on("SIGINT", () => {
	console.log("[SIGINT] Received. Shutting down server...");
	setTimeout(() => { process.exit(0); }, 3000);  // Force quit after 3 seconds
	this.stop();
	process.exit(0);
});

};

module.exports = new App();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants