导入加密时出错 - 尝试更新 React Native 中的一些模块,现在出现加密错误

Error importing Crypto - Tried to update a few modules in React Native and now getting error of crypto

我正在尝试更新 react-navigation,为此我删除了我的 node_modules 文件夹。

但后来它抱怨 crypto,所以我恢复了我 package.json 中的更改,删除了我的 package-lock.json,但不幸的是无法获得我的旧文件夹 node_modules因为我永久删除了它。

有人知道如何解决这个问题吗?

已经尝试了this page所有可能的解决方案,例如删除缓存,通过--save手动添加模块,但不幸的是没有运气。

While trying to resolve module `crypto` from file `/PATH/TO/PROJECT/node_modules/crypto-js/core.js`, the package `/PATH/TO/PROJECT/node_modules/crypto/package.json` was successfully found. However, this package itself specifies a `main` module field that could not be resolved (`/PATH/TO/PROJECT/node_modules/crypto/index.js`. Indeed, none of these files exist:

  * `/PATH/TO/PROJECT/node_modules/crypto/index.js(.native||.ios.expo.ts|.native.expo.ts|.expo.ts|.ios.expo.tsx|.native.expo.tsx|.expo.tsx|.ios.expo.js|.native.expo.js|.expo.js|.ios.expo.jsx|.native.expo.jsx|.expo.jsx|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx|.ios.js|.native.js|.js|.ios.jsx|.native.jsx|.jsx|.ios.json|.native.json|.json|.ios.wasm|.native.wasm|.wasm)`
  * `/PATH/TO/PROJECT/node_modules/crypto/index.js/index(.native||.ios.expo.ts|.native.expo.ts|.expo.ts|.ios.expo.tsx|.native.expo.tsx|.expo.tsx|.ios.expo.js|.native.expo.js|.expo.js|.ios.expo.jsx|.native.expo.jsx|.expo.jsx|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx|.ios.js|.native.js|.js|.ios.jsx|.native.jsx|.jsx|.ios.json|.native.json|.json|.ios.wasm|.native.wasm|.wasm)`
ERROR
10:34
Building JavaScript bundle: error

非常感谢任何帮助。

我正在使用 aws-sdk module,我认为它正在使用 crypto-js,这就是导致此问题的原因。

DO NOT USE THIS VERSION! Please, go for a newer version! It says in the official document.

请使用较新的版本4.0.0

crypto-js (npm package)