我有一个nodejs脚本,它使用phantomjs-node来抓取一个网页.当我从终端窗口运行时它工作正常,但是当我通过Node JS应用程序的运行配置从Webstorm内部运行时,它没有.
什么可能导致Webstorm中的错误?
我已经尝试在注释掉.bash_profile的内容后从终端运行脚本,但它仍然有效.我还检查了process.env另一个示例脚本中的内容,发现Webstorm与终端的值完全不同.
剧本:
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();
});
});
});
});
Run Code Online (Sandbox Code Playgroud)
终端输出(效果很好!):
opened google? success
Page title is Google
Run Code Online (Sandbox Code Playgroud)
Webstorm控制台输出(失败):
/usr/local/bin/node phantom.js
phantom stderr: execvp(): No such file or directory
Process finished with exit code 0
Run Code Online (Sandbox Code Playgroud) 我正在使用WebStorm作为我的节点IDE并且非常喜欢它,但是当我通过WebStorm运行节点时,我无法弄清楚如何使用节点管理器.有没有人得到这个工作?我想我只是不确定如何通过supervisor参数,以便它在启动节点文件时使用它.