我有一个nodejs脚本,它使用phantomjs-node来抓取网页。当我从终端窗口运行时,它工作得很好,但当我通过Node JS应用程序的运行配置从Webstorm内部运行时,情况就不一样了。
Webstorm中的错误可能是什么原因造成的?
在注释掉.bash_profile的内容之后,我已经尝试从终端运行该脚本,它仍然有效。我还检查了另一个示例脚本中的process.env内容,发现Webstorm和terminal中的值完全不同。
脚本:
var phantom = require('phantom');
phantom.create(function(ph) {
return ph.createPage(function(page) {
return page.open("http://www.google.com", function(status) {
console.log("opened google? ", status);
return page.evaluate((function() {
return document.title;
}), function(result) {
console.log('Page title is ' + result);
return ph.exit();
});
});
});
});终端输出(效果很好!):
opened google? success
Page title is GoogleWebstorm控制台输出(失败):
/usr/local/bin/node phantom.js
phantom stderr: execvp(): No such file or directory
Process finished with exit code 0发布于 2012-06-25 14:40:20
Webstorm确实设置了路径变量,但它与应用程序在终端中运行时获得的路径变量不同。我的解决方案,黑客:
Webstorm键入node以进入REPL
完成了!
发布于 2012-06-24 18:55:15
如果你使用的是Mac,请参阅http://devnet.jetbrains.net/docs/DOC-1160。本文档最初是为RubyMine编写的,但它也适用于WebStorm。
https://stackoverflow.com/questions/11175041
复制相似问题