fasttime/JScrewIt

require not working

Closed this issue · 3 comments

When I try to compile const test = require("test") and then I run it with NodeJS v8.1.2 (which uses V8 v5.8.283.41) I get

ReferenceError: require is not defined
    at eval (eval at <anonymous> (C:\Users\H\Desktop\game\dist\server\index.js:1
:2288), <anonymous>:2:14)
    at eval (<anonymous>)
    at Object.<anonymous> (C:\Users\H\Desktop\game\dist\server\index.js:1:2288)
    at Module._compile (module.js:569:30)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
    at Function.Module.runMain (module.js:605:10)
    at startup (bootstrap_node.js:158:16)

When running it directly (without compilation) I don't get any errors.
I'm building with node and JScrewIt.Feature.AUTO

Have I done something wrong or is this actually a bug?

Hi! I'm not very sure what you are trying to achieve. To just compile JScrewIt from the source files, cd into the main directory (where package.json and gulpfile.js are) and run npm run build. That's all.

To compile some JavaScript into JSFuck programmatically using JScrewIt, you could create a minimal script and run it with node:

const JScrewIt = require("jscrewit");
const myJavaScript = 'alert("Hello, World!")';
console.log(JScrewIt.encode(myJavaScript));

You can't require in an eval, so it doesn't work

There is a new section in the readme file that describes some common situations where the output produced by JScrewIt doesn't work as expected. Using require in the input is one of those cases. If that doesn't solve your problem, please add more details.