인프런 커뮤니티 질문&답변
jsx 코드 작성해보기에서 index.js 수정 후 에러 뜹니다.
작성
·
314
1
ERROR in ./src/chapter_03/Library.jsx 5:0-24
Module not found: Error: Can't resolve 'Book' in '/../my-react1/src/chapter_03'
Did you mean './Book'?
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, /../my-react1/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.
어떻게 해야 할까요?
답변 3
1
0
noel75
질문자
네, 아래와 같습니다.
import React from "react";
import Book from 'Book';
function Library(props){
return(
<div>
<Book name="처음 만난 파이썬" numOfPage={300} />
<Book name="처음 만난 AWS" numOfPage={400} />
<Book name="처음 만난 리액트" numOfPage={500} />
</div>
);
}
export default Library;0






Book.jsx파일을 같은 폴더에 작성하셨는지는 모르겠는데,만약
Library.jsx파일과 같은 경로에 작성했다면 아래와 같이import하셔야 합니다.