如何在NodeJS中要求Dagre

时间:2014-10-06 21:49:04

标签: node.js npm require dagre

在使用NPM安装Dagre之后,我正在尝试require Dagre in Node(遵循Dagre维基上的文档)。为什么这不起作用?

$ npm install dagre
dagre@0.5.0 node_modules/dagre
├── graphlib@0.8.0
└── lodash@2.4.1

$ echo -e "var dagre = require('dagre');\nvar g = new dagre.graphlib.Graph();" > app.js

$ node app.js 
/home/username/projects/dagretest/app.js:2
var g = new dagre.graphlib.Graph();
                          ^
TypeError: Cannot read property 'Graph' of undefined
    at Object.<anonymous> (/home/username/projects/dagretest/app.js:2:27)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:906:3

0 个答案:

没有答案