RN 热更新提示 index.js文件找不到

本文详细记录了解决React Native项目在iOS平台打包时遇到的多个错误,包括找不到入口文件、模块命名冲突、依赖问题及端口占用等,并提供了具体的解决步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

问题:

edz$ pushy bundle --platform ios

Bundling with React Native version:  0.44.0

Running bundle command: node node_modules/react-native/local-cli/cli.js bundle --assets-dest build/intermedia/ios --bundle-output build/intermedia/ios/index.bundlejs --dev false --entry-file index.js --platform ios --reset-cache

Scanning 758 folders for symlinks in /Users/edz/Desktop/BitHot/BTHot/node_modules (17ms)

Scanning 758 folders for symlinks in /Users/edz/Desktop/BitHot/BTHot/node_modules (9ms)

jest-haste-map: @providesModule naming collision:

  Duplicate module name: bser

  Paths: /Users/edz/Desktop/BitHot/BTHot/node_modules/react-native/node_modules/bser/package.json collides with /Users/edz/Desktop/BitHot/BTHot/node_modules/react-native/node_modules/fb-watchman/node_modules/bser/package.json

 

This warning is caused by a @providesModule declaration with the same name across two different files.

Loading dependency graph, done.

 

 

Cannot find entry file index.js in any of the roots: ["/Users/edz/Desktop/BitHot/BTHot"]

 

Error: "react-native bundle" command exited with code 1.

    at ChildProcess.reactNativeBundleProcess.on (/usr/local/lib/node_modules/react-native-update-cli/lib/bundle.js:90:16)

    at emitTwo (events.js:126:13)

    at ChildProcess.emit (events.js:214:7)

    at maybeClose (internal/child_process.js:925:16)

    at Socket.stream.socket.on (internal/child_process.js:346:11)

    at emitOne (events.js:116:13)

    at Socket.emit (events.js:211:7)

    at Pipe._handle.close [as _onclose] (net.js:567:12)

 

解决:

001 将index.ios.js文件复制一份将名字改为index.js

002 pushy bundle --platform ios

会提示:

Bundling with React Native version:  0.44.0

Running bundle command: node node_modules/react-native/local-cli/cli.js bundle --assets-dest build/intermedia/ios --bundle-output build/intermedia/ios/index.bundlejs --dev false --entry-file index.js --platform ios --reset-cache

Scanning 758 folders for symlinks in /Users/edz/Documents/BTHot/node_modules (19ms)

Scanning 758 folders for symlinks in /Users/edz/Documents/BTHot/node_modules (16ms)

jest-haste-map: @providesModule naming collision:

  Duplicate module name: bser

  Paths: /Users/edz/Documents/BTHot/node_modules/react-native/node_modules/bser/package.json collides with /Users/edz/Documents/BTHot/node_modules/react-native/node_modules/fb-watchman/node_modules/bser/package.json

 

This warning is caused by a @providesModule declaration with the same name across two different files.

Loading dependency graph, done.

 

warning: the transform cache was reset.

 

 

Unable to resolve module `react-native-update` from `/Users/edz/Documents/BTHot/bthot_src/Configs/update.js`: Module does not exist in the module map or in these directories:

  /Users/edz/Documents/BTHot/node_modules

 

This might be related to https://github.com/facebook/react-native/issues/4968

To resolve try the following:

  1. Clear watchman watches: `watchman watch-del-all`.

  2. Delete the `node_modules` folder: `rm -rf node_modules && npm install`.

  3. Reset packager cache: `rm -fr $TMPDIR/react-*` or `npm start -- --reset-cache`.

Error: "react-native bundle" command exited with code 1.

    at ChildProcess.reactNativeBundleProcess.on (/usr/local/lib/node_modules/react-native-update-cli/lib/bundle.js:90:16)

    at emitTwo (events.js:126:13)

    at ChildProcess.emit (events.js:214:7)

    at maybeClose (internal/child_process.js:925:16)

    at Socket.stream.socket.on (internal/child_process.js:346:11)

    at emitOne (events.js:116:13)

    at Socket.emit (events.js:211:7)

    at Pipe._handle.close [as _onclose] (net.js:567:12)

 

003 watchman watch-del-all

004 rm -rf node_modules && npm install

005 npm start -- --reset-cache

ERROR Packager can't listen on port 8081

Most likely another process is already using this port

Run the following command to find out which process:

 

   lsof -i :8081

 

Then, you can either shut down the other process:

 

   kill -9 <PID>

 

or run packager on different port.

Loading dependency graph...npm ERR! code ELIFECYCLE

npm ERR! errno 11

npm ERR! good@0.0.1 start: `node node_modules/react-native/local-cli/cli.js start "--reset-cache"`

npm ERR! Exit status 11

npm ERR!

npm ERR! Failed at the good@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!     /Users/edz/.npm/_logs/2020-03-09T10_31_15_647Z-debug.log

192:BTHot edz$  lsof -i :8081

COMMAND     PID USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME

Google      561  edz   21u  IPv6 0x30f97137b71608df      0t0  TCP localhost:52382->localhost:sunproxyadmin (ESTABLISHED)

node      68478  edz   17u  IPv6 0x30f97137b5155fdf      0t0  TCP *:sunproxyadmin (LISTEN)

node      68478  edz   19u  IPv6 0x30f97137b716145f      0t0  TCP localhost:sunproxyadmin->localhost:52382 (ESTABLISHED)

 

006 pushy bundle --platform ios

Bundling with React Native version:  0.44.0

Running bundle command: node node_modules/react-native/local-cli/cli.js bundle --assets-dest build/intermedia/ios --bundle-output build/intermedia/ios/index.bundlejs --dev false --entry-file index.js --platform ios --reset-cache

Scanning 758 folders for symlinks in /Users/edz/Documents/BTHot/node_modules (15ms)

Scanning 758 folders for symlinks in /Users/edz/Documents/BTHot/node_modules (25ms)

jest-haste-map: @providesModule naming collision:

  Duplicate module name: bser

  Paths: /Users/edz/Documents/BTHot/node_modules/react-native/node_modules/bser/package.json collides with /Users/edz/Documents/BTHot/node_modules/react-native/node_modules/fb-watchman/node_modules/bser/package.json

 

This warning is caused by a @providesModule declaration with the same name across two different files.

Loading dependency graph, done.

warning: the transform cache was reset.

bundle: start

bundle: finish

bundle: Writing bundle output to: build/intermedia/ios/index.bundlejs

bundle: Done writing bundle output

bundle: Copying 41 asset files

bundle: Done copying assets

Packing

Bundled saved to: build/output/ios.1583749917594.ppk

Would you like to publish it?(Y/N) Y

  Uploading [========================================================] 100% 0.0

Enter version name: 11

Enter description: 11

Enter meta info: 11

Version published: 84999

Would you like to bind packages to this version?(Y/N) Y

 

  ┌────────────┬─────────────────────────────────────┐

  │ Package Id │               Version               │

  ├────────────┼─────────────────────────────────────┤

  │   38692    │  1.2.1(normal) - 84586 Fj1KWriA 1   │

  ├────────────┼─────────────────────────────────────┤

  │   38622    │       1.2.0(normal) (newest)        │

  ├────────────┼─────────────────────────────────────┤

  │   38382    │ 1.1.0(normal) - 84181 FkJLxi7B 1.13 │

  └────────────┴─────────────────────────────────────┘

Total 3 package(s).

Enter Package Id: 38382

Ok.

192:BTHot edz$ ls

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值