Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

代码下载到本地后,为啥执行出错? #15

Open
linlone opened this issue Dec 16, 2016 · 0 comments
Open

代码下载到本地后,为啥执行出错? #15

linlone opened this issue Dec 16, 2016 · 0 comments

Comments

@linlone
Copy link

linlone commented Dec 16, 2016

我的代码结构是这样的(其中t.js是我的测试代码)

$ tree
.
├── CHANGELOG.md
├── demo
│   ├── 1409037825746-1409037838093.png
│   ├── 1409037838093-1409037882033.png
│   ├── 1409037882033-1409037916727.png
│   ├── 1409038130483-1409038137417.png
│   └── ui.png
├── index.js
├── package.json
├── phantomjs
│   ├── diff.js
│   ├── highlight.html
│   ├── highlight.js
│   ├── index.js
│   └── walk.js
├── README.md
├── t.js
└── util.js

$ cat t.js

var index = require('./index.js');

var url = 'http://www.baidu.com';
var monitor = new index.Monitor(url);
monitor.capture(function(code){
console.log(monitor.log); // from phantom
console.log('done, exit [' + code + ']');
});

为了加载phantomjs子目录下的index.js,我改成这样了:

$ head -15 index.js
。。。
var phantomjs = require('./phantomjs/index.js');
var binPath = phantomjs.path;

执行出错了,提示/phantomjs/index.js没有定义:“phantom”,这是为啥呢??

$ node t.js

node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
ReferenceError: phantom is not defined
at Object. (~/Desktop/Share/page-monitor-master/phantomjs/index.js:12:1)
at Module._compile (module.js:441:26)
at Object..js (module.js:459:10)
at Module.load (module.js:348:32)
at Function._load (module.js:308:12)
at Module.require (module.js:354:17)
at require (module.js:370:17)
at Object. (~/Desktop/Share/page-monitor-master/index.js:12:17)
at Module._compile (module.js:441:26)
at Object..js (module.js:459:10)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant