javascript - 在 js 文件上运行 casperjs 时“找不到模块 fs”

标签 javascript node.js phantomjs casperjs

我正在尝试在我拥有的 javascript 文件上运行 CasperJS,当我运行时

> casperjs index.js 

它说

'CasperError: Cant find module fs'. 

index.js第一行是

var fs = require('fs');

我安装了node、casperjs、phantomjs,为什么找不到fs?如果我没记错,fs 是 Node 的文件系统吗?

更新:我将 nodejs 添加到我的 $PATH,但仍然没有成功。

最佳答案

您是否在项目中安装了 PhantomJS/CasperJS 模块以及 Node fs 模块?它们似乎混合得不太好。

我遇到了安装所有这些模块的问题,并且收到了与您上面提到的相同的错误消息。

CasperError: Can't find module fs

卸载 Node “fs”模块后,一切正常。

npm uninstall fs

关于javascript - 在 js 文件上运行 casperjs 时“找不到模块 fs”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39641513/

相关文章:

javascript - 使用带有简单 html 链接的 window.location

node.js - CORS问题: No 'Access-Control-Allow-Origin' header is present on the requested resource

c# - 使用 PhantomJS 下载文件

node.js - nodemon + express,监听端口=?

node.js - Heroku 上的生产构建中显示开发构建错误

javascript - Python爬虫使用Selenium和PhantomJS获取DOM信息

python - 通过 Python 脚本抓取动态网站 : how to get the values?

javascript - 忽略 JSHint 中的全局变量

asp.net - 有没有一种好的方法来保护通过 Javascript 在 HTML 按钮的单击事件处理程序上进行的 ASP.Net Web 服务调用?

javascript - ctrl+c "content"来自 CSS