Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why doesn't the Node console display the function code?

Tags:

node.js

In the Google Chrome console, if I type fn where fn is a function, then I get the code for fn. In the Node console, typing require.resolve simply prints out

[Function] 

Why don't I get the function definition?

like image 298
Randomblue Avatar asked Dec 05 '11 23:12

Randomblue


People also ask

How do I run a function in node JS?

Execute the function. A function can be executed by calling the execute() method in which the function ID and configuration (of type JSON) are passed as parameters. The functions reference used in the code snippets below is the component instance.

Why is node js not working?

Make sure the node path is added, if not added it. After doing this restart Visual Studio or open a fresh command prompt. From the command prompt type 'node -v' to echo the node version installed. You can also add the path to node or any other application directly on the command line.

Why does node print undefined?

node also prints undefined because IN GENERAL, it displays the return value of each command and console. log doesn't return anything. Show activity on this post. this is happening because console.

How does console log work in node?

log() function from console class of Node. js is used to display the messages on the console. It prints to stdout with newline. Parameter: This function contains multiple parameters which are to be printed.


1 Answers

From the comments: use fn.toString().

like image 197
Randomblue Avatar answered Sep 21 '22 19:09

Randomblue