entry point for packager

2020-02-15 03:02发布

问题:

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

instead of

<project-root>

If I run 'node node_modules/react-native/local-cli/cli.js start' it looks for files in the correct location.

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?

Any help greatly appreciated

C

回答1:

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

The temporary solution until RN is fixed (next release?) is to run:

npm start -- -reset-cache

You can also try:

npm run start -- --root <mydir>

This will cause the packager to look in the correct location.

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.

The next release is later this month: https://github.com/facebook/react-native/releases/tag/v0.46.0-rc.0

Update This has now been fixed in release 0.45.1



回答2:

What worked for me was reverting to 0.43.1 (a version that I have other apps working with): delete node_modules, change package.json under dependencies to "react-native": "0.43.1", and npm install. Verify your version with react-native --version, and run again.