'Can't find module fs' when running casperjs on js file

对着背影说爱祢 提交于 2019-12-06 07:31:09

Did you install the PhantomJS/CasperJS modules as well as the node fs module in your project? They don't seem to mix very well.

I ran into an issue where installed all of these modules and I was getting the same error message you mentioned above.

CasperError: Can't find module fs

Once I uninstalled the node 'fs' module, everything worked fine.

npm uninstall fs

Are casperjs and phantomjs installed globally ?

Kata

CasperJS is depending on PhantomJS, which have a built-in fs module. In Casper script, you are only able to use the phantomjs built-in fs module. See http://phantomjs.org/api/fs/

To solve the problem you describe, you will need to make sure there is no fsmodule defined in the package.json, or run npm uninstall fs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!