问题描述
我刚刚开始使用 React Native.一切正常,但是现在当我运行react-native run-ios"时,打包程序正在
I'm just starting out with react native. Everything was going ok but now when I run 'react-native run-ios' the packager is looking for js files in
<project-root>/node_modules/react-native/packager
代替
<project-root>
如果我运行'node node_modules/react-native/local-cli/cli.js start'它会在正确的位置寻找文件.
If I run 'node node_modules/react-native/local-cli/cli.js start'it looks for files in the correct location.
这发生在我现有的项目中,如果我使用 react native init 创建一个新项目.它在我安装新的 npm 模块后开始.我已经恢复更改、重新安装模块、清除 tmpdir 缓存、重新启动计算机等.我可以明确配置打包程序入口点吗?
This is happening in my existing project and if I create a new project using react native init. It started after I installed a new npm module. I've since reverted the change, re-installed modules, cleared the tmpdir cache, rebooted computer etc. Can I explicitly configure the packager entry point?
非常感谢任何帮助
C
推荐答案
这是 RN 0.45 的一个已知问题,我今天从 0.42 升级后也遇到了这个问题.
This is a known issue with RN 0.45, I have also encountered this problem today after upgrading from 0.42.
https://github.com/facebook/react-native/issues/14246
在 RN 修复(下一个版本?)之前的临时解决方案是运行:
The temporary solution until RN is fixed (next release?) is to run:
npm start -- -reset-cache
你也可以试试:
npm run start -- --root <mydir>
这将导致打包程序查找正确的位置.
This will cause the packager to look in the correct location.
在此问题得到纠正之前,这很痛苦,因为这意味着每次从 XCode 或 react-native run-ios
启动打包程序时,我们都必须调用重置.
Until this is corrected it's a pain, as it means we have to invoke the reset every time the packager is started either from XCode or react-native run-ios
.
下一个版本是本月晚些时候:https://github.com/facebook/react-native/releases/tag/v0.46.0-rc.0
The next release is later this month: https://github.com/facebook/react-native/releases/tag/v0.46.0-rc.0
更新此问题现已在 版本 0.45.1
这篇关于打包程序的入口点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!