In case I was not clear above ... in emscripten/src/shell.js, the following test sets the environment to web or node:
ENVIRONMENT_IS_WEB = typeof window === 'object';
ENVIRONMENT_IS_WORKER = typeof importScripts === 'function';
ENVIRONMENT_IS_NODE = typeof process === 'object' && typeof require === 'function' && !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_WORKER;
So once web is detected, node cannot be set. In particular, an Electron web page contains "window" of type "object" and therefore the environment is set to "web", even if node has been enabled within that web page.
As a result, it is not possible to mount the NODEFS file system, even though node is present to do so. Failure takes place in mount() at the assertion in src/library_nodefs.js:
mount: function (mount) {
assert(ENVIRONMENT_IS_NODE);
return NODEFS.createNode(null, '/', NODEFS.getMode(mount.opts.root), 0);
},
Is there a reason why once the web environment is detected, it cannot be reset to node, if node features are present?