我一直试图使用Typescript将nats.io添加到React Native项目中,但出现了很多障碍,我想知道是否有正确的方法在不修改nats的node_modules的情况下这样做(例如,将"fs“导入更改为"react-native-fs”)。这有可能做到吗?谢谢
当我做yarn添加nats或nats@latest时,首先出现的问题之一是:
**util could not be found within the project.
If you are sure the module exists, try these steps:
1. Clear watchman watches: watchman watch-del-all
2. Delete node_modules and run yarn install
3. Reset Metro's cache: yarn start --reset-cache
4. Remove the cache: rm -rf /tmp/metro-*
27 | */
28 | if (typeof TextEncoder === "undefined") {
> 29 | const { TextEncoder, TextDecoder } = require("util");
| ^
30 | global.TextEncoder = TextEncoder;
31 | global.TextDecoder = TextDecoder;
32 | }**发布于 2021-09-15 16:06:57
尝试升级您的节点版本,11+应该有该版本。如果没有,可能是您的捆绑包上的配置阻止了您使用它。
https://stackoverflow.com/questions/69107135
复制相似问题