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