Firefox Addon error: Module `path` is not found at

2019-09-09 20:33发布

问题:

I am writing a Firefox add-on, OS is Windows10, node v5.8.0 and npm v3.5.3, Firefox v.45.0

The line causing the error is:

var path = require("path");

And the error message is:

Message: Module `http` is not found at resource://gre/modules/commonjs/http.js

The following works though:

var system = require("sdk/system");

I tried require with other core modules of node and all of them return the error message above (for instance path and util). It seems like none of the core node modules work or can be found.

I have reistalled node and npm today a few times (following troubleshooting and responses to similar questions), NODE_PATH is set to%AppData%\npm, I have ...\npm\bin and ...\npm\node_modules in my PATH.

Any ideas and help how to resolve the above would be much appreciated.

Many thanks

al

回答1:

Right now, fs/path's doc is empty but using child_process's one, one can infer that the require should be var path = require("sdk/fs/path");