react-native - 无法在 react native 中启动 npm
问题描述
我正在尝试使用 React Native 我尝试使用 npm start运行应用程序
并收到此错误:
> ERROR Metro Bundler can't listen on port 8081 Loading dependency
> graph...npm ERR! code ELIFECYCLE npm ERR! errno 11 npm ERR!
> MyFirstDemo@0.0.1 start: `node
> node_modules/react-native/local-cli/cli.js start` npm ERR! Exit status
> 11 npm ERR! npm ERR! Failed at the MyFirstDemo@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/nidhi/.npm/_logs/2018-09-04T12_11_05_454Z-debug.log
谁能帮我?
解决方案
听起来您已经运行了一个打包程序,或者只是在端口 8081 上运行了其他东西,因此打包程序尝试启动但不能,因为该端口上已经有一些东西正在侦听。
如果你在你的开发机器上,并且没有其他有意义的 node.js 进程在运行,那么你可以执行以下来解决它。
killall node && npm start
如果您不想杀死机器上的每个节点进程,嘿,有些可能很重要……您只想杀死在该端口上运行的进程。
注意:应该适用于 MacOS 和 Linux。
查看该端口上是否有进程(可选步骤)
lsof -i:8081
杀死它(暴力地),假设端口 8081 上有东西在运行
kill -9 $(lsof -t -i:8081)
现在尝试再次运行打包程序。
npm start
推荐阅读
- java - 当您在 Triemap 上使用 Hashmap 时会发生什么情况?
- r - Jupyter Notebook 安装不是“R-essentials”的 R 包
- php - 删除 Guzzle 多部分请求中的 Content-Length 标头
- swift - 什么是[无主的自我],有什么好处?
- python - Matplotlib 热图动画非常小
- web-scraping - 如何在网上大量抓取谷歌缓存?
- c# - 在 Visual Studio 2017 上,如何关闭 try/catch 中的软件?
- c - 使用 malloc 函数的随机数
- android - 如何在 clean-architecture 中传递 android 上下文
- java - Byte Buddy 和 OSGi 编织钩子