리액트에서 caver js를 인스턴스화 할 시에 아래와 같은 웹팩관련된 오류가 뜨는데요

리액트에서 caver js를 인스턴스화 할 시에 아래와 같은 웹팩관련된 오류가 뜨는데요
참고할만한 문서 없을까요.
node에서는 별 문제가 안생기는데 리액트에서 실행하려고하면 문제가 생기네요.

Compiled with problems:X

ERROR in ./node_modules/caver-js/packages/caver-core-requestmanager/caver-providers-http/src/index.js 31:13-28

Module not found: Error: Can’t resolve ‘http’ in ‘C:\Users\doma\Documents\GitHub\thanks_carbon_nft\react-project\node_modules\caver-js\packages\caver-core-requestmanager\caver-providers-http\src’

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.

If you want to include a polyfill, you need to:
- add a fallback ‘resolve.fallback: { “http”: require.resolve(“stream-http”) }’
- install ‘stream-http’
If you don’t want to include a polyfill, you can use an empty module like this:
resolve.fallback: { “http”: false }

ERROR in ./node_modules/caver-js/packages/caver-core-requestmanager/caver-providers-http/src/index.js 33:14-30

Module not found: Error: Can’t resolve ‘https’ in ‘C:\Users\doma\Documents\GitHub\thanks_carbon_nft\react-project\node_modules\caver-js\packages\caver-core-requestmanager\caver-providers-http\src’

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.

If you want to include a polyfill, you need to:
- add a fallback ‘resolve.fallback: { “https”: require.resolve(“https-browserify”) }’
- install ‘https-browserify’
If you don’t want to include a polyfill, you can use an empty module like this:
resolve.fallback: { “https”: false }

ERROR in ./node_modules/caver-js/packages/caver-ipfs/src/index.js 22:11-24

Module not found: Error: Can’t resolve ‘fs’ in ‘C:\Users\doma\Documents\GitHub\thanks_carbon_nft\react-project\node_modules\caver-js\packages\caver-ipfs\src’

ERROR in ./node_modules/caver-js/packages/caver-klay/caver-klay-accounts/src/index.js 42:76-93

Module not found: Error: Can’t resolve ‘crypto’ in ‘C:\Users\doma\Documents\GitHub\thanks_carbon_nft\react-project\node_modules\caver-js\packages\caver-klay\caver-klay-accounts\src’

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.

If you want to include a polyfill, you need to:
- add a fallback ‘resolve.fallback: { “crypto”: require.resolve(“crypto-browserify”) }’
- install ‘crypto-browserify’
If you don’t want to include a polyfill, you can use an empty module like this:
resolve.fallback: { “crypto”: false }

ERROR in ./node_modules/caver-js/packages/caver-utils/randomhex/crypto.js 18:0-34

Module not found: Error: Can’t resolve ‘crypto’ in ‘C:\Users\doma\Documents\GitHub\thanks_carbon_nft\react-project\node_modules\caver-js\packages\caver-utils\randomhex’
Did you mean ‘./crypto’?
Requests that should resolve in the current directory need to start with ‘./’.
Requests that start with a name are treated as module requests and resolve within module directories (node_modules, C:\Users\doma\Documents\GitHub\thanks_carbon_nft\react-project\node_modules).
If changing the source code is not an option there is also a resolve options called ‘preferRelative’ which tries to resolve these kind of requests in the current directory too.

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.

If you want to include a polyfill, you need to:
- add a fallback ‘resolve.fallback: { “crypto”: require.resolve(“crypto-browserify”) }’
- install ‘crypto-browserify’
If you don’t want to include a polyfill, you can use an empty module like this:
resolve.fallback: { “crypto”: false }

ERROR in ./node_modules/caver-js/packages/caver-wallet/src/keyring/keyringHelper.js 24:76-93

Module not found: Error: Can’t resolve ‘crypto’ in ‘C:\Users\doma\Documents\GitHub\thanks_carbon_nft\react-project\node_modules\caver-js\packages\caver-wallet\src\keyring’

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.

If you want to include a polyfill, you need to:
- add a fallback ‘resolve.fallback: { “crypto”: require.resolve(“crypto-browserify”) }’
- install ‘crypto-browserify’
If you don’t want to include a polyfill, you can use an empty module like this:
resolve.fallback: { “crypto”: false }

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

Module not found: Error: Can’t resolve ‘stream’ in ‘C:\Users\doma\Documents\GitHub\thanks_carbon_nft\react-project\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.

If you want to include a polyfill, you need to:
- add a fallback ‘resolve.fallback: { “stream”: require.resolve(“stream-browserify”) }’
- install ‘stream-browserify’
If you don’t want to include a polyfill, you can use an empty module like this:
resolve.fallback: { “stream”: false }

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

Module not found: Error: Can’t resolve ‘crypto’ in ‘C:\Users\doma\Documents\GitHub\thanks_carbon_nft\react-project\node_modules\eth-lib\lib’

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.

If you want to include a polyfill, you need to:
- add a fallback ‘resolve.fallback: { “crypto”: require.resolve(“crypto-browserify”) }’
- install ‘crypto-browserify’
If you don’t want to include a polyfill, you can use an empty module like this:
resolve.fallback: { “crypto”: false }

ERROR in ./node_modules/xhr2-cookies/dist/xml-http-request.js 37:11-26

Module not found: Error: Can’t resolve ‘http’ in ‘C:\Users\doma\Documents\GitHub\thanks_carbon_nft\react-project\node_modules\xhr2-cookies\dist’

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.

If you want to include a polyfill, you need to:
- add a fallback ‘resolve.fallback: { “http”: require.resolve(“stream-http”) }’
- install ‘stream-http’
If you don’t want to include a polyfill, you can use an empty module like this:
resolve.fallback: { “http”: false }

ERROR in ./node_modules/xhr2-cookies/dist/xml-http-request.js 39:12-28

Module not found: Error: Can’t resolve ‘https’ in ‘C:\Users\doma\Documents\GitHub\thanks_carbon_nft\react-project\node_modules\xhr2-cookies\dist’

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.

If you want to include a polyfill, you need to:
- add a fallback ‘resolve.fallback: { “https”: require.resolve(“https-browserify”) }’
- install ‘https-browserify’
If you don’t want to include a polyfill, you can use an empty module like this:
resolve.fallback: { “https”: false }

안녕하세요.
이 링크 참고하시기 바랍니다.

1개의 좋아요

덕분에 해결했습니다. 감사합니다. :slight_smile:

말씀해주신 링크 참고해서

  1. missing moudles들 설치 (npm으로 하나하나 다 설치했습니다!)
  2. webpack.config.js 파일을 루트 폴더에 만들기
  3. webpack.config.js 안에 넣기 (Configuration | webpack 문서에 나와 있는 것들을 넣었습니다!)
  4. resolve fallback 속성을 안에 넣기

했는데 안되길래
2번째 방법인 react-app-rewired를 사용해보려고

스택오버플로우에 관련 글을 찾아 실행해봤는데도 실행이 안되는데 어떤 부분이 문제일까요…?

현재
node-js 버전은 16.13.2
npm 버전은 8.3.0입니다.

Node 버전은 caver-js 리드미에 있는 버전으로 맞춰보시기 바립니다.

혹시 저기 나와 있는 방법 중 어떤 걸로 어떻게 해결하셨는지 궁금합니다…ㅠㅠ

이 오류가 create-react-app 으로 진행했을 시 생기는 오류인 것 같더라구요.
그래서 cra 없이 진행하다 또 기존 다른 개발 했던 부분이랑 충돌나서
cra 이후에 run eject 해서 webpack.config을 자동생성하고
위의 오류에서 말하는 resolve.fallback들이랑 webpack.config에 추가해주고
install 진행했습니다.

그리고 webpack, webpack-cli, webpack-dev-server도 따로 설치를 해줬던걸로 기억하구요.

node-js 버전은 14.17.0입니다.

넵 해결했습니다. 알려주셔서 정말 감사합니다!! 복 받으세요~

2개의 좋아요