我在使用基本的nodejs和express程序时遇到了一些麻烦。
问题是当我使用npm start
时应该运行node。\ bin \ www我收到这些错误:
C:\Users\{USRNAME}\Desktop\projets\cdc\cdc-api>npm start
cdc-api@0.0.0 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! cdc-api@0.0.0 start: `node .\bin\www`
npm ERR! Exit status 8
npm ERR!
npm ERR! Failed at the cdc-api@0.0.0 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 npm@1.4.28
3 info using node@v0.10.32
4 verbose node symlink C:\Program Files\nodejs\\node.exe
5 verbose run-script [ 'prestart', 'start', 'poststart' ]
6 info prestart cdc-api@0.0.0
7 info start cdc-api@0.0.0
8 verbose unsafe-perm in lifecycle true
9 info cdc-api@0.0.0 Failed to exec start script
10 error cdc-api@0.0.0 start: `node .\bin\www`
10 error Exit status 8
11 error Failed at the cdc-api@0.0.0 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上(如果有任何帮助的话)
提前感谢您的帮助(和女孩;))。
答案 0 :(得分:5)
错误&#34; EADDRINUSE&#34;表示您尝试使用的端口已被您的系统使用。尝试更改应用中使用的端口或关闭使用它的任何程序。
答案 1 :(得分:0)
错误表示该端口当前正在使用中。
更新代码以使用其他端口。通常,node.js / express示例会在app.js
中分配端口。
答案 2 :(得分:-1)
EADDRINUSE
在您的代码使用另一个程序的相同端口时发生。
您可以尝试使用另一个端口查看问题是否解决。