如何查看node_modules中哪些函数是公共的和可用的?

时间:2014-11-10 22:55:07

标签: node.js node-modules

我在做MOOC Startup Engineering。它教导如何使用节点,但似乎代码不再起作用。代码位于:

https://spark-public.s3.amazonaws.com/startup/code/market-research.js

我已按以下方式下载了依赖项:

# Install npm dependencies. This will create a node_modules directory in the current working directory. Don't cd into other directories right now; later we'll show how to install modules globally.
npm install restler csv accounting

当我执行node market-research.js时,我收到错误:

/home/ubuntu/market-research.js:47
    csv()
    ^
TypeError: object is not a function
    at csv2console (/home/ubuntu/market-research.js:47:5)
    at Request.response2console (/home/ubuntu/market-research.js:65:13)
    at Request.emit (events.js:98:17)
    at Request.mixin._fireSuccess (/home/ubuntu/node_modules/restler/lib/restler.js:226:10)
    at /home/ubuntu/node_modules/restler/lib/restler.js:158:20
    at IncomingMessage.parsers.auto (/home/ubuntu/node_modules/restler/lib/restler.js:394:7)
    at Request.mixin._encode (/home/ubuntu/node_modules/restler/lib/restler.js:195:29)
    at /home/ubuntu/node_modules/restler/lib/restler.js:154:16
    at Request.mixin._decode (/home/ubuntu/node_modules/restler/lib/restler.js:170:7)
    at IncomingMessage.<anonymous> (/home/ubuntu/node_modules/restler/lib/restler.js:147:14)

由于代码包含var csv = require('csv');,我试图弄清楚它是否实际导入。

如果我理解得很好, node_modules 中的某个地方必须是exports.csv= csv;有没有办法检查哪些变量或函数已导出?

我写过exports。节点返回:ReferenceError: exports is not defined

1 个答案:

答案 0 :(得分:0)

如果你想让它工作,修改你的package.json,在“依赖项”中更改csv的版本号,但我不记得哪个版本csv()

查看公共函数列表最简单的方法是在具有node_modules的项目文件夹中打开bash / cmd / console终端。

node -> hit enter
var csv = require('csv');
csv. -> then hit tab couple of times