react-native – 为什么npm start会给我一个关于端口的错误?
发布时间:2020-12-15 16:18:52 所属栏目:百科 来源:网络整理
导读:我输入“npm start”后,我不知道为什么它会给我错误.我正在尝试使用相同的WIFI打开我的React Native项目.我认为这是关于港口的. 这是错误: Loading dependency graph...events.js:183 throw er; // Unhandled 'error' event ^Error: listen EADDRINUSE :::8
我输入“npm start”后,我不知道为什么它会给我错误.我正在尝试使用相同的WIFI打开我的React Native项目.我认为这是关于港口的.
这是错误: Loading dependency graph...events.js:183 throw er; // Unhandled 'error' event ^ Error: listen EADDRINUSE :::8081 at Server.setupListenHandle [as _listen2] (net.js:1360:14) at listenInCluster (net.js:1401:12) at Server.listen (net.js:1485:7) at D:rnprojectstestprojectnode_modulesmetrosrcindex.js:156:18 at new Promise (<anonymous>) at Object.<anonymous> (D:rnprojectstestprojectnode_modulesmetrosrcindex.js:155:12) at Generator.next (<anonymous>) at step (D:rnprojectstestprojectnode_modulesmetrosrcindex.js:47:262) at D:rnprojectstestprojectnode_modulesmetrosrcindex.js:47:422 at <anonymous> npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! testproject@0.0.1 start: `node node_modules/react-native/local- cli/cli.js start` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the testproject@0.0.1 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! C:UsersASUSAppDataRoamingnpm-cache_logs2018-09- 29T06_20_58_251Z-debug.log 在npm开始后: 解决方法
可能端口已经在使用中.当我第一次运行react-native run-android然后npm start时,我面临类似的问题.我像这样解决它:
首先,获取在端口8081中运行的进程的id: sudo lsof -i :8081 然后杀了它: kill -9 ID_SHOWN_FROM_PREVIOUS_CMD ID_SHOWN_FROM_PREVIOUS_CMD将类似于25534所以在它之后,先运行npm start然后使用react-native run-android (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |