我正在尝试在第三方NPM模块(如果有帮助的话,使用Typescript)中使用redux-persist
。每当我尝试在实际项目(这是一个运行良好的React Native应用程序)中使用第三方模块(本地链接)时,都会出现以下错误:
error: bundling failed: Error: Unable to resolve module `react-native` from
`path/to/my/3rd/party/module/node_modules/redux-persist/lib/storage/index.native.js`:
Module `react-native` does not exist in the Haste module map
Redux-persist指出它不需要React(正如它在自述文件中所说的“如果您正在使用react ...”,这意味着它也可以在没有React / React Native的情况下使用),为什么我得到了这样的错误?
我尝试过的事情:
react
(任何版本)添加为我的外部模块的对等依赖项react-native
(任何版本)添加为我的外部模块的对等依赖项react
安装到我的外部模块react-native
安装到我的外部模块@next
的{{1}}版本,该版本对React的依赖关系进行了一些更改。我也读过https://github.com/rt2zz/redux-persist/issues/833和https://github.com/rt2zz/redux-persist/pull/919,但不确定该怎么做。我总是清除缓存,重新启动VScode和bundler等。
尽管我仍然遇到相同的错误。如何将redux-persist正确集成到我的party npm软件包中(可能与或不与React / React Native一起使用)