1212 project C-prac

연주·2023년 1월 30일
0

KDT-TIL

목록 보기
36/36
  1. cra 환경으로 typescript 환경 구축
    npx create-react-app my-app --template typescript

  2. typescript에서 navermapAPI를 쓰기 위해 설치

npm install --save @types/navermaps

3.index.html 해당 내용 추가

<script type="text/javascript" src="https://openapi.map.naver.com/openapi/v3/maps.js?ncpClientId=발급받은아이디"></script>

여기, 발급받은 아이디를 숨기기 위해서, 환경변수 사용

  1. 최상위 폴더에 .env을 만든 후,
    REACT_APP_NAVER_ID=발급받은아이디
    를 저장 시킨후,
    .gitignore.env를 꼭 추가시킨다.

  2. index.html 수정

<script type="text/javascript" src="https://openapi.map.naver.com/openapi/v3/maps.js?ncpClientId=%REACT_APP_NAVER_ID%"></script>

안전하게 나의 정보를 숨길 수 있다.


  • react-naver-maps 설치가 계속 되지 않았다.

버전 문제인거 같았다.
node_modules 폴더를 삭제하고,
다시 아래대로 설치한 후,
npm config set legacy-peer-deps true
npm install

react-naver-maps 를 설치했더니 설치가 되었다.

profile
성장중인 개발자🫰

0개의 댓글