I'm writing a node-webkit application (based on node-webkit-hipster-seed) and I'm trying to import additional node modules. I've found that even if I attempt to import default node modules (such as fs and http) I get the following error:
var http = require('http');
AssertionError: missing path
with the stack trace:
"AssertionError: missing path
at Module.require (module.js:359:3)
at require (module.js:376:17)
at window.require (eval at undefined, <anonymous>:1:112)
at _require (file:///Users/...project/_public/js/vendor.js:92:38)
at require (file:///Users/...project/_public/js/vendor.js:162:16)
at eval (eval at undefined, <anonymous>:2:6)
at Object.InjectedScript._evaluateOn (eval at undefined, <anonymous>:603:39)
at Object.InjectedScript._evaluateAndWrap (eval at undefined, <anonymous>:562:52)
at Object.InjectedScript.evaluate (eval at undefined, <anonymous>:481:21)"
I'm not sure what's going on. Is something mangling require that I don't know about? Is this require not the CommonJS require?
It turns out that the issue was that I also had ace.js loaded, which also assigns a global require function.
To solve this, you can add the following code snippet: (source)
<script type="text/javascript">
window.requireNode = window.require;
window.require = undefined;
</script>
in the head of your main html file. Then just use requireNode instead of require.