reactjs-带有"fs"的phantomjs节点问题;模块 [英] reactjs - phantomjs-node issues with "fs" module
本文介绍了reactjs-带有"fs"的phantomjs节点问题;模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用phantomjs-node捕获屏幕.在我的组件中,导入const phantom = require('phantom');
.然后单击后,我要运行方法-
I am trying to use phantomjs-node to capture screen. In my component i import const phantom = require('phantom');
. Then after click i want to run method -
printOnePage(){
phantom.create().then(function(ph) {
ph.createPage().then(function(page) {
page.open('https://stackoverflow.com/').then(function(status) {
console.log(status);
page.property('content').then(function(content) {
console.log(content);
page.close();
ph.exit();
});
});
});
});
}
但是我仍然是gettint错误-
But i am still gettint error -
webpack:///./~/phantomjs-prebuilt/lib/phantomjs.js?:8 Uncaught Error: Cannot find module "fs"(…)
任何提示怎么办?
推荐答案
看起来像是webpack的配置错误.关于该错误的问题提示该块
Looks like a webpack misconfiguration. An issue on the error suggests that a block
node: {
fs: "empty"
}
需要添加到webpack配置中.另一种补救方法看来,可能是添加一个选项>
needs to be added to the webpack config. Another remedy, it seems, could be to add an option
target: 'node',
到webpack配置.
to the webpack config.
这篇关于reactjs-带有"fs"的phantomjs节点问题;模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文