SpookyJS:添加一些依赖项后无法执行hello.js

时间:2016-03-10 08:36:29

标签: javascript node.js spookyjs

我git将spookyjs从github克隆到我的shell,然后npm install并运行node examples/hello.js

一切顺利,hello.js输出:

Hello, from Spooky the Tuff Little Ghost - Wikipedia, the free encyclopedia

然后我将一些依赖项添加到package.json:

  "dependencies": {
    "underscore": "1.3.x",
    "async": "0.1.x",
    "tiny-jsonrpc": "0.2.x",
    "carrier": "0.1.x",
    "duplexer": "0.0.x",
    "readable-stream": "~1.0.2"
  }

  "dependencies": {
    "underscore": "1.3.x",
    "async": "0.1.x",
    "tiny-jsonrpc": "0.2.x",
    "carrier": "0.1.x",
    "duplexer": "0.0.x",
    "readable-stream": "~1.0.2",

    "express": "^4.13.4",
    "bluebird": "^3.3.4",
    "body-parser": "~1.13.2",
    "consul": "^0.23.0",
    "cookie-parser": "~1.3.5",
    "debug": "~2.2.0",
    "express": "~4.13.1",
    "jade": "~1.11.0",
    "morgan": "~1.6.1",
    "native-dns": "^0.7.0",
    "node-phantom": "^0.2.5",
    "serve-favicon": "~2.3.0",
    "util": "^0.10.3",
    "webpage": "^0.3.0"
  }

然后我npm install,再次运行node examples/hello.js。但现在它因奇怪的日志而失败了:

{ id: 1,
  code: -32603,
  message: 'undefined is not a constructor (evaluating \'require(\'webpage\').create()\')' }
{ id: 2, code: -32603, message: 'Type error' }
{ id: 3, code: -32603, message: 'Type error' }

我的问题是,为什么向SpookyJS添加一些依赖会导致这样的错误,以及如何避免此错误?

1 个答案:

答案 0 :(得分:0)

将该问题发布到github。 SpookyJS(草坪)的主要开发人员回答我:

  

听起来这个包(网页)与本机有冲突   PhantomJS模块网页。你将无法一起使用它们。

     

我认为您无法使用名为网页的软件包。你可以   创建另一个以不同名称包装它的npm包。