2014-10-21 85 views
0

我對基本nodejs和express程序有點麻煩。無法啓動nodejs + express基本程序

問題是,當我使用npm start應該運行節點\ BIN \ WWW我得到這些錯誤:

C:\Users\{USRNAME}\Desktop\projets\cdc\cdc-api>npm start 

[email protected] start C:\Users\{USRNAME}\Desktop\projets\cdc\cdc-api 
node .\bin\www 


events.js:72 
     throw er; // Unhandled 'error' event 
      ^
Error: listen EADDRINUSE 
    at errnoException (net.js:904:11) 
    at Server._listen2 (net.js:1042:14) 
    at listen (net.js:1064:10) 
    at Server.listen (net.js:1138:5) 
    at Function.app.listen (C:\Users\{USRNAME}\Desktop\projets\cdc\cdc-api\node_mo 
dules\express\lib\application.js:556:24) 
    at Object.<anonymous> (C:\Users\{USRNAME}\Desktop\projets\cdc\cdc-api\bin\www: 
7:18) 
    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) 

npm ERR! [email protected] start: `node .\bin\www` 
npm ERR! Exit status 8 
npm ERR! 
npm ERR! Failed at the [email protected] start script. 
npm ERR! This is most likely a problem with the cdc-api package, 
npm ERR! not with npm itself. 
npm ERR! Tell the author that this fails on your system: 
npm ERR!  node .\bin\www 
npm ERR! You can get their info via: 
npm ERR!  npm owner ls cdc-api 
npm ERR! There is likely additional logging output above. 
npm ERR! System Windows_NT 6.2.9200 
npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nod 
ejs\\node_modules\\npm\\bin\\npm-cli.js" "start" 
npm ERR! cwd C:\Users\{USRNAME}\Desktop\projets\cdc\cdc-api 
npm ERR! node -v v0.10.32 
npm ERR! npm -v 1.4.28 
npm ERR! code ELIFECYCLE 
npm ERR! 
npm ERR! Additional logging details can be found in: 
npm ERR!  C:\Users\{USRNAME}\Desktop\projets\cdc\cdc-api\npm-debug.log 
npm ERR! not ok code 0 

C:\Users\{USRNAME}\Desktop\projets\cdc\cdc-api> 

和這裏是我在NPM-的debug.log:

0 info it worked if it ends with ok 
1 verbose cli [ 'C:\\Program Files\\nodejs\\\\node.exe', 
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js', 
1 verbose cli 'start' ] 
2 info using [email protected] 
3 info using [email protected] 
4 verbose node symlink C:\Program Files\nodejs\\node.exe 
5 verbose run-script [ 'prestart', 'start', 'poststart' ] 
6 info prestart [email protected] 
7 info start [email protected] 
8 verbose unsafe-perm in lifecycle true 
9 info [email protected] Failed to exec start script 
10 error [email protected] start: `node .\bin\www` 
10 error Exit status 8 
11 error Failed at the [email protected] start script. 
11 error This is most likely a problem with the cdc-api package, 
11 error not with npm itself. 
11 error Tell the author that this fails on your system: 
11 error  node .\bin\www 
11 error You can get their info via: 
11 error  npm owner ls cdc-api 
11 error There is likely additional logging output above. 
12 error System Windows_NT 6.2.9200 
13 error command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start" 
14 error cwd C:\Users\Moucheg\Desktop\projets\cdc\cdc-api 
15 error node -v v0.10.32 
16 error npm -v 1.4.28 
17 error code ELIFECYCLE 
18 verbose exit [ 1, true ] 

我已經嘗試了所有我在互聯網上找到的東西(重新安裝節點,重新創建package.json,...)我無法讓它工作。

僅供參考,我在Windows 8(如果它的任何幫助)

預先感謝您的幫助球員(女孩))。

回答

5

錯誤「EADDRINUSE」表示您嘗試使用的端口已被您的系統使用。嘗試更改應用中使用的端口或關閉正在使用的任何程序。

+0

作爲一個後續,檢出libuv [這裏]的錯誤代碼列表(http://nikhilm.github.io/uvbook/basics.html#error-handling)。這將極大地幫助您調試Node應用程序。 – 2014-10-21 22:04:10

+0

-_-我一定是地球上最倒黴的人,我曾考慮過這個,試圖改變它三次,但沒有改變任何東西。謝謝 !! – Moucheg 2014-10-21 22:13:26

0

該錯誤表示該端口當前正在使用中。 更新代碼以使用不同的端口。通常情況下,node.js/express樣本將分配app.js中的端口。