ERROR

export 'Routes' (imported as 'Routes') was not found in 'react-router-dom'

ㅇㄱ9 2022. 6. 16. 21:00
728x90

https://www.npmjs.com/package/react-router-dom

 

 

react-router-dom

Declarative routing for React web applications. Latest version: 6.3.0, last published: 3 months ago. Start using react-router-dom in your project by running `npm i react-router-dom`. There are 14337 other projects in the npm registry using react-router-dom

www.npmjs.com

react-router-dom 라이브러리가 5버전에서 6버전으로 넘어가면서 <Switch>가  <Routes>로 변경되었다. 

 

프로젝트의 package.json에는 아래와 같이 나와있음에도 app 빌드시 에러가 났다. 

"react-router-dom": "^6.3.0"
 
 
해당 라이브러리 설치 삭제를 하고 다시 빌드해봐도 동일한 컴파일 에러가 났다. 
 
아래와 같이 버전을 지정해서 설치하여 해결하였다.
npm install react-router-dom@6.3.0

 

728x90
반응형