问题
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();
});
});
});
});
}
But i am still gettint error -
webpack:///./~/phantomjs-prebuilt/lib/phantomjs.js?:8 Uncaught Error: Cannot find module "fs"(…)
Any tips what to do ?
回答1:
Looks like a webpack misconfiguration. An issue on the error suggests that a block
node: {
fs: "empty"
}
needs to be added to the webpack config. Another remedy, it seems, could be to add an option
target: 'node',
to the webpack config.
来源:https://stackoverflow.com/questions/41032928/reactjs-phantomjs-node-issues-with-fs-module