【发布时间】:2013-12-17 20:57:56
【问题描述】:
我只是想运行html-snapshots。这应该很容易吧?
这是我开始的:
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)
wtf?
其他信息...
这是 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
【问题讨论】:
-
这个错误来自图书馆吗?也许它缺少一些依赖项。检查并查看
inputGenerator是什么,以及它是否是required -
谢谢@Houseman,你让我意识到安装机器人是错误的做法。 input-generators 文件夹中有一个 robots.js 由于某种原因没有被加载。 (不是说我已经解决了我的问题)
-
如果你真的想感谢我,你可以点赞我的评论。 :)
-
@GilBirman,你用的是什么版本的
html-snapshots?我已经检查了版本“0.2.1”并且引发错误var inputGenerator = inputFactory.create(options.input);的语句在第 42 行(不是您的错误中的 43)。所以你可以使用旧版本或者html-snapshots\lib\html-snapshots.js已经修改。我建议从node_modules中删除整个html-snapshots目录,使用npm再次下载并应用我提供的修复程序。您应该不会再遇到第二个错误。 -
谢谢汤姆。这消除了错误。
标签: javascript node.js installation npm