我如何获得HTML快照的工作?

我只是试图运行HTML快照 。 这应该很简单吧?

这是我开始的:

npm install html-snapshots 

这就是我需要的,对吧? 这是我的snapshots.js文件:

 var htmlSnapshots = require('html-snapshots'); htmlSnapshots.run({ source: "sitemap.xml", hostname: "localhost", outputDir: "snapshots", outputDirClean: true, selector: "#results-widget" }); 

并运行它:

 node snapshots.js 

但是,

 module.js:340 throw err; ^ Error: Cannot find module '.\robots' at Function.Module._resolveFilename (module.js:338:15) at Function.Module._load (module.js:280:25) at Module.require (module.js:364:17) at require (module.js:380:17) at Object.module.exports.create (C:\webdev\node_modules\html-snapshots\lib\input-generators\index.js:38:16) at Object.module.exports.run (C:\webdev\node_modules\html-snapshots\lib\html-snapshots.js:42:39) at Object.<anonymous> (C:\webdev\snapshots.js:2:15) at Module._compile (module.js:456:26) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) 

跆拳道?

附加信息…

这是html-snapshots.js的一部分:

 var inputFactory = require("./input-generators"); ... run: function(options, listener) { ... var inputGenerator = inputFactory.create(options.input); ... result = inputGenerator.run(options, (function(options, notifier){ 

另外, html-snapshots\lib\input-generators文件夹包含文件robots.js

它在html-snapshots\lib\input-generators\index.js文件中看起来像一个问题 – 在Linux系统上工作正常,但在Windows上失败( path.sep已被用于构build模块名称)

问题是它应该加载'./robots'模块而不是'.\robots'

快速修复是更新html-snapshots\lib\input-generators\index.js文件 – 第38行。

换行:

 result = require(file); 

至:

 result = require(path.join(__dirname, file)); 

它会正常工作。 我希望这会有所帮助。