错误:无法加载包本地主机:8081

IT技术 reactjs react-native
2021-05-08 10:29:21

我在运行 react-native run-ios 时遇到了一个问题,显示以下消息,我认为它与 babel 相关:

react本机包错误

请问有人已经有这个问题了吗?

"GET /index.bundle?platform=ios&dev=true&minify=false HTTP/1.error: bundling failed: Error: Unable to resolve module `@babel/runtime/helpers/interopRequireDefault` from `/Volumes/SD/react/PropertyFinder/index.js`: Module `@babel/runtime/helpers/interopRequireDefault` does not exist in the Haste module map

谢谢

4个回答

我有同样的问题。我尝试安装

npm 添加@babel/runtime

然后

安装

它对我有用,我希望它可以帮助你。

有时不同的程序使用相同的端口,如 80,8080 或 8081,当我遇到这个问题时,我将默认端口设置为 8088。它运行完美。

尝试

react-native run-ios --port=8088

如果更改端口不起作用,请尝试此操作。这会将 @babel/runtime 包安装到您的项目中。

npm add @babel/runtime

npm install

在此之后重新编译您的项目。

我希望它有效。

有效的解决方案:

rm -rf ios/build/; kill $(lsof -t -i:8081)

打开文件'package.json' => 在“scripts”中添加“build:ios”

"scripts": {
   "build:ios": "react-native bundle --entry-file='index.js' --bundle- 
                 output='./ios/main.jsbundle' --dev=false --platform='ios'",
}

npm 运行构建:ios