我尝试使用命令**“npm start”**启动React Js服务器,但在控制台上显示以下错误:
prateek@localhost:~/WebstormProjects/untitled> npm start
> untitled@0.1.0 start /home/prateek/WebstormProjects/untitled
> react-scripts start
Could not find an open port at localhost.localdomain.
Network error message: getaddrinfo ENOTFOUND localhost.localdomain
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! untitled@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the untitled@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/prateek/.npm/_logs/2017-09-29T05_33_18_507Z-debug.log
我在Linux上使用npm 5.3.0和node 8.4.0。
下面的npm日志文件:
0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node8', '/usr/bin/npm-default', 'start' ]
2 info using npm@5.3.0
3 info using node@v8.4.0
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle untitled@0.1.0~prestart: untitled@0.1.0
6 info lifecycle untitled@0.1.0~start: untitled@0.1.0
7 verbose lifecycle untitled@0.1.0~start: unsafe-perm in lifecycle true
8 verbose lifecycle untitled@0.1.0~start: PATH: /usr/lib64/node_modules/npm8/bin/node-gyp-bin:/home/prateek/WebstormProjects/untitled/node_modules/.bin:/usr/lib64/mpi/gcc/openmpi/bin:/usr/local/bin:/usr/bin:/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin
9 verbose lifecycle untitled@0.1.0~start: CWD: /home/prateek/WebstormProjects/untitled
10 silly lifecycle untitled@0.1.0~start: Args: [ '-c', 'react-scripts start' ]
11 silly lifecycle untitled@0.1.0~start: Returned: code: 1 signal: null
12 info lifecycle untitled@0.1.0~start: Failed to exec start script
13 verbose stack Error: untitled@0.1.0 start: `react-scripts start`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (/usr/lib64/node_modules/npm8/lib/utils/lifecycle.js:289:16)
13 verbose stack at emitTwo (events.js:125:13)
13 verbose stack at EventEmitter.emit (events.js:213:7)
13 verbose stack at ChildProcess.<anonymous> (/usr/lib64/node_modules/npm8/lib/utils/spawn.js:40:14)
13 verbose stack at emitTwo (events.js:125:13)
13 verbose stack at ChildProcess.emit (events.js:213:7)
13 verbose stack at maybeClose (internal/child_process.js:927:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
14 verbose pkgid untitled@0.1.0
15 verbose cwd /home/prateek/WebstormProjects/untitled
16 verbose Linux 4.11.8-2-default
17 verbose argv "/usr/bin/node8" "/usr/bin/npm-default" "start"
18 verbose node v8.4.0
19 verbose npm v5.3.0
20 error code ELIFECYCLE
21 error errno 1
22 error untitled@0.1.0 start: `react-scripts start`
22 error Exit status 1
23 error Failed at the untitled@0.1.0 start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
有人能告诉我如何修复这个错误吗?
2条答案
按热度按时间j2cgzkjk1#
在OpenSUSE上,要修复getaddrinfo ENOTFOUND localhost.localdomain错误问题,您可以尝试:
验证HOST环境变量设置是否正确,可以运行**
echo $HOST
查看其当前值,如果不正确或缺失,可以在终端运行export HOST=localhost
**进行设置。wqsoz72f2#
运行
sudo lsof -n -i :3000 | grep LISTEN
命令,然后关闭使用该端口的程序或使用sudo kill {PID}
(用第一个命令找到的PID替换{PID})。