include - Why does require('underscore') return undefined when executed at the node.js REPL? -


When I run a node in my console and requires var _ = ('underscore'); , _ is undefined finishes if I put the same code in a file and execute it, the underscores library is included as expected.

  $ node> Var _ = is required ('underscore'); & Gt; Console.log (_) undefined // underscore library does not load & gt; Var async = require ('async'); Undefined & gt; Console.log (async) // async library {noConflict: [function], next tick: [function], for hech: [function], ... & gt;  

But the same code in a .js file executed in the form of node test.js shows that both the libraries are loading as expected. What is happening?

Adds the node rep to the value of _ with the value of the final evaluation input ; Which overwrites var_ = ... ... in your _ bindings. See also.

It does not matter which varies ... , for example:

  $ node> Var _ = "no value"; Undefined & gt; _define  

Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -