首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >反应-本机-npm-开始不工作给错误与地铁- events.js:183抛出器

反应-本机-npm-开始不工作给错误与地铁- events.js:183抛出器
EN

Stack Overflow用户
提问于 2019-04-29 09:29:38
回答 1查看 700关注 0票数 0

我试图从Linux服务器在Android上运行一个本机应用程序,现在我在尝试用npm-start'启动npm服务器时遇到了这个错误。

代码语言:javascript
复制
> test0app@0.0.1 start /home/lenovot430/Documents/ReactProjects/test0app
> node node_modules/react-native/local-cli/cli.js start

┌──────────────────────────────────────────────────────────────────────────────┐
│                                                                              │
│  Running Metro Bundler on port 8081.                                         │
│                                                                              │
│  Keep Metro running while developing on any JS projects. Feel free to        │
│  close this tab and run your own Metro instance if you prefer.               │
│                                                                              │
│  https://github.com/facebook/react-native                                    │
│                                                                              │
└──────────────────────────────────────────────────────────────────────────────┘

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 Promise (/home/lenovot430/Documents/ReactProjects/test0app/node_modules/metro/src/index.js:253:20)
    at new Promise (<anonymous>)
    at Object.<anonymous> (/home/lenovot430/Documents/ReactProjects/test0app/node_modules/metro/src/index.js:252:14)
    at Generator.next (<anonymous>)
    at asyncGeneratorStep (/home/lenovot430/Documents/ReactProjects/test0app/node_modules/metro/src/index.js:46:24)
    at _next (/home/lenovot430/Documents/ReactProjects/test0app/node_modules/metro/src/index.js:66:9)
    at <anonymous>
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! test0app@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 test0app@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!     /home/lenovot430/.npm/_logs/2019-04-29T09_09_45_424Z-debug.log

如果我尝试‘react原生运行-android’,应用程序就会卡在加载屏幕上。

我试图修复它的方法

  1. 删除节点模块,清理缓存并重新安装。 rm -rf node_modules && npm cache clean --force && npm install
  2. 卸载和重新安装的守望者 brew uninstall watchman brew link pcre brew install --HEAD watchman brew install watchman
  3. 克隆看门人回购并试用4.9.0版 $ git clone https://github.com/facebook/watchman.git $ cd watchman $ git checkout v4.9.0 # the latest stable release $ ./autogen.sh $ ./configure $ make $ sudo make install

我没有在react本机应用程序中进行任何配置更改。我试着用react-native init做一个新项目,但在这个项目中,我也遇到了同样的错误。

我的package.json文件

代码语言:javascript
复制
{
  "name": "test0app",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "react": "16.8.3",
    "react-native": "0.59.5"
  },
  "devDependencies": {
    "@babel/core": "^7.4.4",
    "@babel/runtime": "^7.4.4",
    "babel-jest": "^24.7.1",
    "jest": "^24.7.1",
    "metro-react-native-babel-preset": "^0.53.1",
    "react-test-renderer": "16.8.3"
  },
  "jest": {
    "preset": "react-native"
  }
}
EN

回答 1

Stack Overflow用户

发布于 2019-08-05 09:52:26

您有错误,Error: listen EADDRINUSE :::8081,意思是“使用中的地址”。

有时,使用绑定器启动的web服务器无法正确地关闭,从而使端口8081保持锁定。您可以使用以下方法找到流氓进程:

代码语言:javascript
复制
lsof -wni tcp:8081

然后通过PID杀死它

代码语言:javascript
复制
kill -9 <PID>

我必须这么做,两周左右。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55900472

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档