我试图从Linux服务器在Android上运行一个本机应用程序,现在我在尝试用npm-start'启动npm服务器时遇到了这个错误。
> 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’,应用程序就会卡在加载屏幕上。
我试图修复它的方法
rm -rf node_modules && npm cache clean --force && npm installbrew uninstall watchman brew link pcre brew install --HEAD watchman brew install watchman$ 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文件
{
"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"
}
}发布于 2019-08-05 09:52:26
您有错误,Error: listen EADDRINUSE :::8081,意思是“使用中的地址”。
有时,使用绑定器启动的web服务器无法正确地关闭,从而使端口8081保持锁定。您可以使用以下方法找到流氓进程:
lsof -wni tcp:8081然后通过PID杀死它
kill -9 <PID>我必须这么做,两周左右。
https://stackoverflow.com/questions/55900472
复制相似问题