taro 3.5.6 RN 引入 expo-camera ,dev:h5 报错

kwvwclae  于 2022-10-24  发布在  其他
关注(0)|答案(2)|浏览(229)

相关平台

React Native

复现仓库

https://github.com/StarHosea/taro-exam-rn.git

使用框架: React

复现步骤

  • taro init 选择 gitee react-native 模板,
  • 修改 pages/index/index.ts 引入 expo-camera ,h5 报错

Module parse failed: Unexpected token (12:12)
node_modules/react-native/Libraries/EventEmitter/RCTDeviceEventEmitter.js
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
|
| import EventEmitter from '../vendor/emitter/EventEmitter';
import type {IEventEmitter} from '../vendor/emitter/EventEmitter';
|
| // FIXME: use typed events

  • 重启 dev:h5 ,控制台一直报错

Module parse failed: Unexpected token (12:12)
node_modules/react-native/Libraries/EventEmitter/RCTDeviceEventEmitter.js
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
|
| import EventEmitter from '../vendor/emitter/EventEmitter';
import type {IEventEmitter} from '../vendor/emitter/EventEmitter';
|
| // FIXME: use typed events

期望结果

expo-camera 支持 web, 期望dev:h5 可以正常运行

实际结果

dev:h5 报错

环境信息

Taro CLI 3.5.6 environment info:
    System:
      OS: Windows 10
    Binaries:
      Node: 16.13.2 - C:\Program Files\Volta\node.EXE
      Yarn: 1.22.19 - C:\Program Files\Volta\yarn.EXE
      npm: 8.1.2 - C:\Program Files\Volta\npm.EXE
qij5mzcb

qij5mzcb1#

用webpack配一下
react-native-web 的 alias

ntjbwcob

ntjbwcob2#

https://necolas.github.io/react-native-web/docs/setup/#package-aliasing

相关问题