# Caver-js 모듈 에러문제 문의

**URL:** <https://devforum.kaia.io/t/caver-js/3655>\
**Category:** Caver\
**Tags:** caver-js\
**Created:** [2월 9, 2022, 12:56오전 UTC](https://devforum.kaia.io/t/caver-js/3655 "2022-02-09T00:56:55Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![I\_Do\_Love](https://yyz1.discourse-cdn.com/flex035/user_avatar/devforum.kaia.io/i_do_love/32/1752_2.png) [@I\_Do\_Love](https://devforum.kaia.io/u/I_Do_Love)\
**Post date:** [2월 9, 2022, 12:56오전 UTC](https://devforum.kaia.io/t/caver-js/3655/1 "2022-02-09T00:56:56Z")

</div>

안녕하세요  
klaytn\_address로 caver-js를 이용하여 balance구하려고 하는중에 caver-js 모듈을 깔면 아래와같이 에러메세지가 쭉 뜨더라구요…

그래서 에러에 해당하는 모듈들(install ‘stream-http’, install ‘https-browserify’, install ‘url’, install ‘crypto-browserify’, install ‘stream-browserify’, )을 설치했더니 그래도 계속 같은 에러가 떠서 문의를 남깁니다. ㅠㅠ

> 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 ‘/Users/imhyeonjeong/Desktop/blockchain/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 ‘/Users/imhyeonjeong/Desktop/blockchain/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-core-requestmanager/caver-providers-ws/src/helpers.js 14:14-28  
> Module not found: Error: Can’t resolve ‘url’ in ‘/Users/imhyeonjeong/Desktop/blockchain/node\_modules/caver-js/packages/caver-core-requestmanager/caver-providers-ws/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: { “url”: require.resolve(“url/”) }’  
> - install ‘url’  
> If you don’t want to include a polyfill, you can use an empty module like this:  
> resolve.fallback: { “url”: false }

> 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 ‘/Users/imhyeonjeong/Desktop/blockchain/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 ‘/Users/imhyeonjeong/Desktop/blockchain/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, /Users/imhyeonjeong/Desktop/blockchain/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 ‘/Users/imhyeonjeong/Desktop/blockchain/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 ‘/Users/imhyeonjeong/Desktop/blockchain/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 ‘/Users/imhyeonjeong/Desktop/blockchain/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 ‘/Users/imhyeonjeong/Desktop/blockchain/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 }

---

<div class="post-metadata">

**Author:** ![margintop3498](https://yyz1.discourse-cdn.com/flex035/user_avatar/devforum.kaia.io/margintop3498/32/1750_2.png) [@margintop3498](https://devforum.kaia.io/u/margintop3498)\
**Post date:** [2월 9, 2022, 1:47오전 UTC](https://devforum.kaia.io/t/caver-js/3655/2 "2022-02-09T01:47:16Z")

</div>

안녕하세요 제가 예상하는 시나리오는 다음과 같습니다.

`create-react-app` 을 사용하여 리엑트 보일러플레이트를 생성하고

`caver-js`를 설치하여 모듈을 불러왔는데 제대로 로드되지않았다.

위 내용이 맞다면 오류를 다음과같이 해결할 수 있을것같습니다.

“react-scripts”: “5.0.0” → “react-scripts”: “4.0.3” 변경 후 모듈 재설치 후

`yarn start` or `npm run start`

이렇게 하시면 해결될것으로 보입니다.

`react-scripts` 5.x를 사용하여 하는 방법은 webpack config 파일을 수정하는 방법은 있지만 eject하거나 wrapping 해야하므로 추천드리지 않습니다.

---

<div class="post-metadata">

**Author:** ![I\_Do\_Love](https://yyz1.discourse-cdn.com/flex035/user_avatar/devforum.kaia.io/i_do_love/32/1752_2.png) [@I\_Do\_Love](https://devforum.kaia.io/u/I_Do_Love)\
**Post date:** [2월 9, 2022, 10:53오후 UTC](https://devforum.kaia.io/t/caver-js/3655/3 "2022-02-09T22:53:13Z")

</div>

답변 감사합니다.  
“react-scripts”: “4.0.3” 변경 후 모듈 재설치 후 실행을 하려하니 에러가 전보다 더 많이뜨고 npm start가 안됩니다…ㅠㅠ

“react-scripts”: “5.0.0” 를 사용할때는 아래와같은 에러가뜨는데 js파일들에는 오류가안뜨고 모듈다운문제같은데 뭐가 잘못된건지 모르겠습니다ㅠㅠ…

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/klaytn/original/2X/c/c258868181f12187d93936a0b363c4a75a45cb96.jpeg)

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/klaytn/original/2X/c/c64e1888de367bf139c3042423489ce3b48b549d.png)

---

<div class="post-metadata">

**Author:** ![margintop3498](https://yyz1.discourse-cdn.com/flex035/user_avatar/devforum.kaia.io/margintop3498/32/1750_2.png) [@margintop3498](https://devforum.kaia.io/u/margintop3498)\
**Post date:** [2월 9, 2022, 11:57오후 UTC](https://devforum.kaia.io/t/caver-js/3655/4 "2022-02-09T23:57:53Z")

</div>

node\_modules 폴더를 삭제하고 npm install 해보시겠어요?

그리고 npm run start후 어떤 오류가 나는지 첨부 부탁드립니다.

---

<div class="post-metadata">

**Author:** ![I\_Do\_Love](https://yyz1.discourse-cdn.com/flex035/user_avatar/devforum.kaia.io/i_do_love/32/1752_2.png) [@I\_Do\_Love](https://devforum.kaia.io/u/I_Do_Love)\
**Post date:** [2월 10, 2022, 12:14오전 UTC](https://devforum.kaia.io/t/caver-js/3655/5 "2022-02-10T00:14:33Z")

</div>

“react-scripts”: “5.0.0” 를 사용하고 node\_modules 폴더를 삭제후에 npm install caver-js 하고 터미널에 발생한 에러화면입니다.

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/klaytn/original/2X/b/bffa725b182045cbfd646c5b5f754585ea35dc68.jpeg)

npm start 한 화면입니다!  
계속 같은에러가 나네요…

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/klaytn/original/2X/b/b74beb9b1c63668446244ebe31b11b1444cfe079.jpeg)  
 ![image](https://canada1.discourse-cdn.com/flex035/uploads/klaytn/original/2X/4/4af7cc91d4ddae06ecce6bbeb6680432ff84cc13.jpeg)  
 ![image](https://canada1.discourse-cdn.com/flex035/uploads/klaytn/original/2X/6/612f78c868321ff9946a1c4bd9e40bf0d8225b88.jpeg)  
 ![image](https://canada1.discourse-cdn.com/flex035/uploads/klaytn/original/2X/0/057cab002a3231067c01a2941b5496d303cc1ccb.jpeg)  
 ![image](https://canada1.discourse-cdn.com/flex035/uploads/klaytn/original/2X/8/8903064118e8fce6130f0eb4a14721cc1e9b285b.png)  
 ![image](https://canada1.discourse-cdn.com/flex035/uploads/klaytn/original/2X/c/c077e50826114bdb1afe15cd62d7f857a1523e68.jpeg)  
 ![image](https://canada1.discourse-cdn.com/flex035/uploads/klaytn/original/2X/4/43d5cb0592a550d9d86e7222f30c904fc3bbe39e.jpeg)  
 ![image](https://canada1.discourse-cdn.com/flex035/uploads/klaytn/original/2X/7/79f4f75a00f8bb8d3a00c9de02e0cb9a484fa768.jpeg)  
 ![image](https://canada1.discourse-cdn.com/flex035/uploads/klaytn/original/2X/4/4e8785c2f12a7f7f15bab266fe531cbb3e95e1bc.png)  
 ![image](https://canada1.discourse-cdn.com/flex035/uploads/klaytn/original/2X/5/5b67e8b19061d0941734260460dcf9b7b1c0cc8c.png)  
 ![image](https://canada1.discourse-cdn.com/flex035/uploads/klaytn/original/2X/4/4a2ad9bbff1f07bf6a3b7e267b04336b8343a549.jpeg)

---

<div class="post-metadata">

**Author:** ![margintop3498](https://yyz1.discourse-cdn.com/flex035/user_avatar/devforum.kaia.io/margintop3498/32/1750_2.png) [@margintop3498](https://devforum.kaia.io/u/margintop3498)\
**Post date:** [2월 10, 2022, 12:18오전 UTC](https://devforum.kaia.io/t/caver-js/3655/6 "2022-02-10T00:18:38Z")

</div>

자 처음부터 다시 해보겠습니다.

5.0.0을 사용하여 해결하는 방법은 따로 알려드리지 않았습니다.

일단 package.json안의 react-scripts 버전을 4.0.3으로 변경해주세요.

저장하시고 터미널에서 node\_modules를 제거합니다.

다시 터미널에 npm install 합니다.

설치가 완료되면 다시 터미널에 npm run start

이렇게 진행하고 나오는 오류를 전달부탁드립니다 😁

---

<div class="post-metadata">

**Author:** ![I\_Do\_Love](https://yyz1.discourse-cdn.com/flex035/user_avatar/devforum.kaia.io/i_do_love/32/1752_2.png) [@I\_Do\_Love](https://devforum.kaia.io/u/I_Do_Love)\
**Post date:** [2월 10, 2022, 12:23오전 UTC](https://devforum.kaia.io/t/caver-js/3655/7 "2022-02-10T00:23:25Z")

</div>

react-scripts 버전을 4.0.3으로 사용을할경우에는 아예 실행조차 되지않습니다…ㅠ

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/klaytn/original/2X/4/4a283847558c755d1156218eb452b9b361119627.jpeg)  
 ![image](https://canada1.discourse-cdn.com/flex035/uploads/klaytn/original/2X/f/f4097bd9e97b75c3b3495ed7f940921d1b4abda3.jpeg)

---

<div class="post-metadata">

**Author:** ![Kale](https://yyz1.discourse-cdn.com/flex035/user_avatar/devforum.kaia.io/kale/32/148_2.png) [@Kale](https://devforum.kaia.io/u/Kale)\
**Post date:** [2월 10, 2022, 12:45오전 UTC](https://devforum.kaia.io/t/caver-js/3655/8 "2022-02-10T00:45:41Z")

</div>

안녕하세요.

먼저 질문에 대답을 드리기전에 궁금하신 내용 혹은 발생한 에러에 대한 해결법이 있는지 검색을 해보셨는지요?

살펴보니 webpack과 관련된 문제로 보이는데, 이미 webpack과 관련된 문의가 많이 올라왔었고 담당자가 대응했던 것으로 알고 있습니다.

> [@리액트에서 caver js를 인스턴스화 할 시에 아래와 같은 웹팩관련된 오류가 뜨는데요](https://devforum.kaia.io/t/caver-js/3520):
>
> 리액트에서 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…

caver-js의 repo에도 webpack관련된 에러가 발생 시 어떻게 하면 되는지 가이드를 하고 있습니다.

> **[GitHub - klaytn/caver-js: Official caver-js repository](https://github.com/klaytn/caver-js#using-webpack--5)**
>
> Official caver-js repository. Contribute to klaytn/caver-js development by creating an account on GitHub.

참고 부탁드리겠습니다.

---

<div class="post-metadata">

**Author:** ![margintop3498](https://yyz1.discourse-cdn.com/flex035/user_avatar/devforum.kaia.io/margintop3498/32/1750_2.png) [@margintop3498](https://devforum.kaia.io/u/margintop3498)\
**Post date:** [2월 10, 2022, 12:50오전 UTC](https://devforum.kaia.io/t/caver-js/3655/9 "2022-02-10T00:50:13Z")

</div>

보내주신 내용에서

아래와 같이 진행해보니 정상적으로 caver-js를 사용할 수 있음을 확인했습니다.

아래 내용으로 확인 부탁드리겠습니다.

```auto
✗ rm package-lock.json
✗ rm -r node_modules
✗ npm install webpack@4.44.2
✗ npm run start

```

---

<div class="post-metadata">

**Author:** ![I\_Do\_Love](https://yyz1.discourse-cdn.com/flex035/user_avatar/devforum.kaia.io/i_do_love/32/1752_2.png) [@I\_Do\_Love](https://devforum.kaia.io/u/I_Do_Love)\
**Post date:** [2월 10, 2022, 1:31오전 UTC](https://devforum.kaia.io/t/caver-js/3655/10 "2022-02-10T01:31:45Z")

</div>

답변 정말 감사합니다. 👍  
위에 답변해주신분을 보고 다시 해결해보겠습니다!!

---

<div class="post-metadata">

**Author:** ![Euije.lee](https://avatars.discourse-cdn.com/v4/letter/e/b2d939/32.png) [@Euije.lee](https://devforum.kaia.io/u/Euije.lee)\
**Post date:** [2월 17, 2022, 3:00오전 UTC](https://devforum.kaia.io/t/caver-js/3655/11 "2022-02-17T03:00:06Z")

</div>

안녕하세요 동일 오류로 문제를 겪고 있습니다.  
혹시 해결 하셨다면 최종 어떤 방법으로 해결 하셨는지 알 수 있을까요?

---

<div class="post-metadata">

**Author:** ![sujine](https://yyz1.discourse-cdn.com/flex035/user_avatar/devforum.kaia.io/sujine/32/794_2.png) [@sujine](https://devforum.kaia.io/u/sujine)\
**Post date:** [2월 17, 2022, 5:53오전 UTC](https://devforum.kaia.io/t/caver-js/3655/12 "2022-02-17T05:53:21Z")

</div>

제가 이거 해결했는데

node\_modules \> react-script \> webpack.config.js 보시면 resolve 쪽이 있습니다. 거기에 fallback{ }, 넣으시고 저기 에러 뜬 내용들 하나씩 모두 추가하시면 해결 됩니다.  
즉,  
resolve : {  
fallback : {  
“fs” : false ,  
“http”: require.resolve(“stream-http”),  
“https”: require.resolve(“https-browserify”), …

}  
}  
이런식으로 오류나는 거 모두 추가해 주시면 됩니다. 이후에도 xh2-cookie 관련 오류가 난다면 npm i로 설치를, 그래도 안된다면 node\_modules , package-lock.json 삭제 후 재설치 와 위의 webpack.config 파일 수정하시면 됩니다

---

<div class="post-metadata">

**Author:** ![sujine](https://yyz1.discourse-cdn.com/flex035/user_avatar/devforum.kaia.io/sujine/32/794_2.png) [@sujine](https://devforum.kaia.io/u/sujine)\
**Post date:** [2월 17, 2022, 5:54오전 UTC](https://devforum.kaia.io/t/caver-js/3655/13 "2022-02-17T05:54:05Z")

</div>

웹팩이 버전 5으로 업데이트 되면서 저렇게 하나씩 추가해주어야 로드됩니다.

---

<div class="post-metadata">

**Author:** ![Euije.lee](https://avatars.discourse-cdn.com/v4/letter/e/b2d939/32.png) [@Euije.lee](https://devforum.kaia.io/u/Euije.lee)\
**Post date:** [2월 17, 2022, 7:12오전 UTC](https://devforum.kaia.io/t/caver-js/3655/14 "2022-02-17T07:12:26Z")

</div>

npm install 이후 (https-browserify, url)  
node\_modules \> react-script \> config \> webpack.config.js 수정해서 해결했습니다.  
감사합니다.

---

<div class="post-metadata">

**Author:** ![relician](https://yyz1.discourse-cdn.com/flex035/user_avatar/devforum.kaia.io/relician/32/1413_2.png) [@relician](https://devforum.kaia.io/u/relician)\
**Post date:** [2월 17, 2022, 8:54오전 UTC](https://devforum.kaia.io/t/caver-js/3655/15 "2022-02-17T08:54:20Z")

</div>

node는 생 초짜라 계속 환경 구성을 못하고 있었습니다.  
그래도 해야 하다 보니 …

caver-js@1.6.7 설치 하고 한참 삽질 했었는데,  
위엣 분이 남겨주신 글 보고서

1. webpack@4.44.2 로 설치하고 나서,
2. webpack.config.js 파일에서

```auto
  node: {
    fs: 'empty'
  },

```

했더니 돌기 시작하네요.

고맙습니다.
