As some commentators have noted, you may be using the code in the wrong place (i.e. unprivileged, web page context). However, this may just be a review issue.
If this is a field of view, try the following:
const {Cc,Ci,Cu} = require("chrome"); var file = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile); file.initWithPath(filePath);
If you work in the wrong place, require will create an error.
source share