dougwilson/nodejs-depd

TypeError: eval is not a function

Closed this issue · 8 comments

Recently my app keeps exploding because of this error from depd:

./node_modules/depd/index.js:410
  var deprecatedfn = eval('(function (' + args + ') {\n' +
                     ^

TypeError: eval is not a function

I think node.js removed eval() completely in favor of VM: https://nodejs.org/api/vm.html

depd is a dep of a lot of modules in my case: express, http-errors, send and body-parser

So, my question is why is depd v2.x not being released already to solve this mayhem properly?

The eval function is still a part of Node.js.

Then why am I getting this error on app start on 2 different computers, with 2 different Node.js versions?

In the current case I'm using: Node.js v8.11.4 (latest LTS on their site is v8.12.0)

I'm not using Electron, NW.js or anything else, just Node.js

Also, I had no problems in the past, this started happening recently.

I'm not sure. I just tried it out and the function is there still for me:

$ node -e 'console.log(process.version);console.log(typeof eval);console.log(eval("4 + 1"))'
v8.11.4
function
5

and

$ node -e 'console.log(process.version);console.log(typeof eval);console.log(eval("4 + 1"))'
v8.12.0
function
5

Perhaps if you can provide the full steps to reproduce on my end I can help determine why you're having the issue, but without any steps to reproduce, you'll likely need to debug through it or open an issue on the Node.js repo if your binaries are missing a core function.

One would also think that your report wouldn't be the first and only one (https://github.com/dougwilson/nodejs-depd/issues?utf8=%E2%9C%93&q=is:issue+%22eval+is+not+a+function%22) if eval was really removed from Node.js with this module being in things like express, no? 8.11.4 was released Aug 16, so it seems like someone else would have upgraded to that version of Node.js by now and reported the same issue?

This is indeed very strange, your terminal command works for me too:

$ node -e 'console.log(process.version);console.log(typeof eval);console.log(eval("4 + 1"))'
v8.11.4
function
5

But I can't imagine how that error could mean anything else, or be caused by anything else.

I'll try to make a simplistic test case to see if it's reproducible on a small scale, otherwise it may be that my app is somehow breaking it, although i can't currently comprehend how it could break eval like this.

holy mother of god, i debugged it and found the issue, thanks for taking the time to put me straight

for your enjoyment, i was using a deobfuscation script found online, which after reading it thoroughly, it does, and I quote:

eval = window.eval = write = document.write = writeln = document.writeln = createPopup = window.createPopup = createElement = document.createElement = appendChild = beautify

jesus christ..

it's annoying that it proved itself to be the best deobfuscation script out there

What the what? That is pretty mind blowing. I'm glad you found the issue. I would have been happy to re-open if there was something we had to change to fix something, of course 👍