0

我 git clone aspookyjs从 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导致这样的错误,如何避免这个错误?

4

1 回答 1

0

将该问题发布到github。SpookyJS(lawnsea) 的主要开发者回答我:

听起来那个包(网页)与本机 PhantomJS 模块网页冲突。您将无法同时使用它们。

我认为您将无法使用名为网页的包。您可以创建另一个 npm 包,将其包装在不同的名称下。

于 2016-03-16T07:05:44.427 回答