【问题标题】:Multiple issues with webpack, polyfill and node modules [duplicate]webpack,polyfill和节点模块的多个问题[重复]
【发布时间】:2022-02-08 20:28:14
【问题描述】:

我正在尝试构建一个调用智能合约的简单反应应用程序,但是在运行时 - 我遇到了 webpack、节点模块的多个问题。 大多数问题都指向解决错误 这个反应应用程序是使用 create-react-app 模块创建的。 以下是错误

ERROR in ../node_modules/cipher-base/index.js 3:16-43

Module not found: Error: Can't resolve 'stream' in 'C:\Sandip@IBM\BlockChainDev\MultiSigWallet\node_modules\cipher-base'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

类似的其他错误

ERROR in ../node_modules/eth-lib/lib/bytes.js 7:193-227

Module not found: Error: Can't resolve 'crypto' in 
ERROR in ../node_modules/swarm-js/node_modules/eth-lib/lib/bytes.js 9:193-227
ERROR in ../node_modules/web3-eth-accounts/lib/index.js 33:74-91

ERROR in ../node_modules/web3-providers-http/lib/index.js 30:11-26

Module not found: Error: Can't resolve 'http' in 

我对如何解决这些依赖错误有点迷茫。

谢谢

【问题讨论】:

标签: reactjs webpack node-modules create-react-app solidity


【解决方案1】:

如果我的猜测是正确的,那么您使用的是react-script 5.0 + 请使用"react-scripts": "4.0.3", 这个问题是因为 webpack 配置。 有几种方法可以解决这个问题,但我认为这种方法很简单。

【讨论】:

  • 我需要在哪里更改版本?如何降级 react 的版本?
  • 只需编辑 package.json 和 npm install。这将自动降级 react-script 版本
  • 谢谢...我修改了版本并在客户端文件夹中运行 npm install...现在 npm 服务器无法启动,出现其他一些错误,例如 -- 可能有问题项目依赖树。这可能不是 Create React App 中的错误,而是您需要在本地修复的错误。 Create React App 提供的 react-scripts 包需要依赖:"webpack": "4.44.2"
  • 你的 react 版本是多少?
  • "_id": "react@17.0.2",
猜你喜欢
  • 2022-10-17
  • 2023-03-09
  • 1970-01-01
  • 1970-01-01
  • 2018-07-10
  • 2015-03-31
  • 1970-01-01
  • 2019-11-03
  • 1970-01-01
相关资源
最近更新 更多