【发布时间】:2016-09-27 21:50:22
【问题描述】:
节点版本 v5.4.1,我在当前目录的 node_modules 中安装了 lodash。我遇到了这个问题,其中 '_' 似乎很特别。
> var _ = require('lodash');
undefined
> _.defaults
TypeError: Cannot read property 'defaults' of undefined
at repl:1:2
at REPLServer.defaultEval (repl.js:252:27)
at bound (domain.js:287:14)
at REPLServer.runBound [as eval] (domain.js:300:12)
at REPLServer.<anonymous> (repl.js:417:12)
at emitOne (events.js:82:20)
at REPLServer.emit (events.js:169:7)
at REPLServer.Interface._onLine (readline.js:210:10)
at REPLServer.Interface._line (readline.js:549:8)
at REPLServer.Interface._ttyWrite (readline.js:826:14)
> var l = require('lodash');
undefined
> l.defaults
[Function]
>
我看到了a question related to undefined output。但是,当'_'作为变量名时,'require'的失败是没有问题的。你知道吗?
【问题讨论】:
标签: node.js