当我运行node app.js
时,我得到:
Error: Cannot find module '/home/jchan1/projects/versiv-api/node_modules/pg/lib/native/../../build/default/binding'
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.<anonymous> (/home/jchan1/projects/versiv-api/node_modules/pg/lib/native/index.js:17:13)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
因为上面的错误说明pg
,我会做npm install pg
,但这是我得到的错误:
jchan1@ubuntu ^___^V: $ npm install pg
/
> pg@3.4.0 install /home/jchan1/projects/versiv-api/node_modules/pg
> node-gyp rebuild || (exit 0)
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: 503 status code downloading tarball
gyp ERR! stack at Request.<anonymous> (/home/jchan1/.nvm/v0.10.33/lib/node_modules/npm/node_modules/node-gyp/lib/install.js:246:14)
gyp ERR! stack at Request.emit (events.js:117:20)
gyp ERR! stack at Request.onResponse (/home/jchan1/.nvm/v0.10.33/lib/node_modules/npm/node_modules/request/request.js:1085:10)
gyp ERR! stack at ClientRequest.g (events.js:180:16)
gyp ERR! stack at ClientRequest.emit (events.js:95:17)
gyp ERR! stack at HTTPParser.parserOnIncomingClient (http.js:1692:21)
gyp ERR! stack at HTTPParser.parserOnHeadersComplete [as onHeadersComplete] (http.js:121:23)
gyp ERR! stack at Socket.socketOnData (http.js:1587:20)
gyp ERR! stack at TCP.onread (net.js:527:27)
gyp ERR! System Linux 3.13.0-39-generic
gyp ERR! command "node" "/home/jchan1/.nvm/v0.10.33/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/jchan1/projects/versiv-api/node_modules/pg
gyp ERR! node -v v0.10.33
gyp ERR! node-gyp -v v1.0.1
gyp ERR! not ok
pg@3.4.0 node_modules/pg
├── packet-reader@0.2.0
├── pg-connection-string@0.1.1
├── buffer-writer@1.0.0
├── pg-types@1.4.0
├── generic-pool@2.0.3
├── nan@0.6.0
└── pgpass@0.0.3 (split@0.3.3)
我使用node
v0.10.33,python2.7
在Ubuntu 14.04上安装了build-essentials
,make
和g++
。< / p>
jchan1@ubuntu ^___^V: $ nvm list
v0.10.25
-> v0.10.33
system
default -> v0.10.33
node -> stable (-> v0.10.33) (default)
stable -> 0.10 (-> v0.10.33) (default)
iojs -> iojs- (-> N/A) (default)
jchan1@ubuntu ^___^V: $ npm -v
1.4.28
jchan1@ubuntu ^___^V: $ nodejs -v
v0.10.33
jchan1@ubuntu ^___^V: $ node -v
v0.10.33
jchan1@ubuntu ^___^V: $ make -v
GNU Make 3.81
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
This program built for x86_64-pc-linux-gnu
jchan1@ubuntu ^___^V: $ g++ --version
g++ (Ubuntu 4.8.2-19ubuntu1) 4.8.2
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.