๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
Study

[React] ์ ˆ๋Œ€ ๊ฒฝ๋กœ ์„ค์ •ํ•˜๊ธฐ

by JulesJ 2022. 3. 2.
728x90

๊ฐœ๋ฐœ ํ™˜๊ฒฝ : Mac + VScode + React + js

 

 

.์ด๋‚˜ ..์„ ์ด์šฉํ•ด ../component/Header์™€ ๊ฐ™์ด ์ƒ๋Œ€ ๊ฒฝ๋กœ๋กœ ์ž‘์„ฑํ•˜๋ฉด, ์ƒ๋Œ€๊ฒฝ๋กœ์ด๊ธฐ ๋•Œ๋ฌธ์— ํ•ด๋‹น ํด๋”๋‚˜ ํŒŒ์ผ ์ด๋™ํ•  ๋•Œ ๊ฒฝ๋กœ๊ฐ€ ๋‹ฌ๋ผ์ ธ import ์˜ค๋ฅ˜๊ฐ€ ๋‚  ์ˆ˜ ์žˆ๋‹ค.
ํ˜น์€ ์‚ฌ์šฉํ•  ๋•Œ ํ—ท๊ฐˆ๋ฆด ์ˆ˜๋„ ์žˆ๋‹ค..

๋”ฐ๋ผ์„œ 'import {Header} from 'component/Header'์™€ ๊ฐ™์ด ์ ˆ๋Œ€๊ฒฝ๋กœ๋ฅผ ์ด์šฉํ•˜๋ฉด ํŽธํ•˜๊ณ ,
๊ฒฝ๋กœ ์˜ค๋ฅ˜ ๋ฌธ์ œ๋„ ํ•ด๊ฒฐ ๊ฐ€๋Šฅํ•˜๋‹ค.

 

ํ•ด๊ฒฐ๋ฐฉ๋ฒ•

๊ฒ€์ƒ‰ํ•˜๋‹ˆ env๋ฅผ ์ด์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•๋„ ์žˆ๋Š”๋ฐ ์•„๋ž˜ ๋ฐฉ๋ฒ•์œผ๋กœ ๊ฐ„๋‹จํžˆ ํ•ด๊ฒฐํ•  ์ˆ˜ ์žˆ์–ด์„œ, ์•„๋ž˜ ๋ฐฉ๋ฒ•๋งŒ ๋‹ด์•˜๋‹ค.
์ด ๋ฐฉ๋ฒ•์œผ๋กœ ../.์˜ ์ง€์˜ฅ์„ ํƒˆ์ถœํ–ˆ๋‹ค..

jsconfig.json ํŒŒ์ผ์„ ๋งŒ๋“ค๊ณ , ์•„๋ž˜ ์ฝ”๋“œ๋ฅผ ์‚ฝ์ž…ํ•œ๋‹ค.

json ํŒŒ์ผ์˜ ์œ„์น˜๋Š” package.jsonํŒŒ์ผ๊ณผ ๋™์ผํ•œ ์œ„์น˜์— ์ƒ์„ฑํ•œ๋‹ค.

(typescript์ผ ๊ฒฝ์šฐ tsconfig.json์œผ๋กœ ํŒŒ์ผ์„ ์ƒ์„ฑํ•œ๋‹ค.)

 

 

jsconfig.json

{
    "compilerOptions": {
        "baseUrl": "src"
    },
    "includes": [
        "src"
    ]
}

 


References

- https://velog.io/@rimo09/React%EC%97%90%EC%84%9C-%EC%BB%B4%ED%8F%AC%EB%84%8C%ED%8A%B8-%EA%B2%BD%EB%A1%9C-%EA%B9%94%EB%81%94%ED%9E%88-%EA%B4%80%EB%A6%AC%ED%95%98%EA%B8%B0 (2022.03.02)

 

- https://velog.io/@mollang/React-%EC%A0%88%EB%8C%80%EA%B2%BD%EB%A1%9C-%EC%84%A4%EC%A0%95 (2022.03.02)

 

 

 

๋๐Ÿง

 

๋Œ“๊ธ€