[typescript] 카이카스(Kaikas) caver-js 지갑연동 webpack < 5 Error (Module not found)
Klaytn / Kaikas / caver-js / webpack / react-scripts / 클레이튼 / KAS
Caver-js
‘caver-js’ 는 개발자가 HTTP 또는 웹소켓 연결을 사용하여 Klaytn 노드와 상호작용할 수 있도록하는 자바스크립트 API 라이브러리
설치 👉
npm install caver-js
불러오기 👉
import Caver from "caver-js"
클레이튼 ‘Kaikas’ 지갑 연동 코드 👆
- https://docs.kaikas.io/02_api_reference/01_klaytn_provider
(👆 kaikas Docs 공식 문서 - 지갑연동)
Module not found Error
npm start
로 잘 실행되던 코드가
caver-js 를 적용한 코드 때문에 실행되지 않았다
package.json 수정작업
package.json 에서
“react-scripts” 버전을 낮추는 작업
"5.0.1" 👉👉👉 "4.0.2"
(5 버전 이하면 다 실행이 된다)
버전을 낮추고 수정 후에는
npm install
을 해줘야 적용이 된다 !
참고 했던 사이트 🖥
발생했던 에러 내용
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 ‘/home/wavescats/문서/BEB-04-Klaypod/client/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-ipfs/src/index.js 22:11-24 Module not found: Error: Can’t resolve ‘fs’ in ‘/home/wavescats/문서/BEB-04-Klaypod/client/node_modules/caver-js/packages/caver-ipfs/src’