I've been trying to use the FS API in PhantomJS, but I get an error I'm not able to understand when I run the following code
private[scalajssupport] object PhantomFile {
val fs: PhantomFS = js.Dynamic.global.require("fs").asInstanceOf[PhantomFS]
}
The error I get is:
TypeError: undefined is not a constructor (evaluating '$g["require"]("fs")')
However, when I run
var fs = global["require"]("fs")
directly in the PhantomJS REPL, it's working fine.