๐์ฝ๋ฉ ๊ณต๋ถ
Nest.js ) Circular dependency ์ค๋ฅ ํด๊ฒฐ ๊ธฐ๋ก
* a → b : a์ b๋ฅผ ์ฃผ์ ์ํด / a์ b๋ฅผ import ํจ - ๋ชจ๋ ์๊ฐ MainModule : ์๋น์ค์ ๊ด๋ จ๋ ๋ชจ๋, ์ปจํธ๋กค๋ฌ, DB ๋ฐ์ดํฐ ๋ฑ์ ๊ด๋ฆฌ UserModule : ์ฌ์ฉ์ ์ ๋ณด๋ฅผ ์ฒ๋ฆฌํ๋ ๋ชจ๋ DataModule : DB์ ํต์ ํ๋ฉฐ ๋ฐ์ดํฐ๋ฅผ ์ฒ๋ฆฌํ๋ ๋ชจ๋ UtilModule: Util์ฑ ์ฝ๋ ๋ฐ ์๋น์ค๋ค ๋ชจ์ SomeUtil : DB๋ฐ์ดํฐ๋ฅผ ํ์ฉํ์ฌ ํน์ ์์ญ๊ณผ ๊ด๋ จ๋ ์ฒ๋ฆฌ๋ฅผ ํ๋ ์๋น์ค - ๋ฐฐ๊ฒฝ ์ ๋ชจ๋์๊ฐ์ ๊ฐ์ด DB๋ฐ์ดํฐ๋ฅผ ํ์ฉํ์ฌ ํน์ ๋ฐ์ดํฐ๋ฅผ ์ฒ๋ฆฌํ Util์ฑ ์๋น์ค๊ฐ ํ์ํด์ก๋ค. ์ด๋ SomeUtil์ MainModule ์๋์ ์๋ UserModule์ ์ฐ์ฌ์ผ ํ๋ค. UserModule์ DataModule์ ์ฌ์ฉํ๊ณ ์์๊ณ , ๋ ๋ชจ๋ ๋ชจ๋ UtilModule์ impo..
Nest.js ) Circular dependency ๋ฒ์ญ
์๋ฌธ: https://docs.nestjs.com/fundamentals/circular-dependency Circular dependency A circular dependency occurs when two classes depend on each other. For example, class A needs class B, and class B also needs class A. Circular dependencies can arise in Nest between modules and between providers. ์ํ ์ข ์์ฑ์ ๋ ํด๋์ค๊ฐ ์๋ก ์ข ์๋ ๋ ๋ฐ์ํ๋ค. ์๋ฅผ ๋ค์ด, ํด๋์คA๊ฐ ํด๋์ค B๋ฅผ ํ์๋กํ๊ณ , ๋ํ ํด๋์คB๊ฐ ํด๋์ค A๋ฅผ ํ์๋ก ํ๋ ๊ฒฝ์ฐ์ด๋ค. ์ํ ์ข ์์ฑ์ ๋ชจ๋๊ณผ ํ๋ก๋ฐ์ด๋..
Nest.js) ์์กด์ฑ, ์ฃผ์ ๊ด๋ จ์ค๋ฅ / Error: Nest can't resolve dependencies of ... ์๋ฌด๋ฆฌํด๋ ํด๊ฒฐ์ด ์๋ ๋ (Feat. chatGPT)
1. Inject ํ ๋ Cannot read properties of undefine passportStrategy์์ Service๋ฅผ ์ฃผ์ ํ์๋ ์ ์ค๋ฅ๊ฐ ๋ฐ์ํ๋ค. โถ๏ธ ๋น ๋ฅธ ๊ฒฐ๋ก ๋ฐ๋ณด๊ฐ์ด Strategy์ @Injectable() ๋ฐ์ฝ๋ ์ดํฐ๋ฅผ ์๋ถ์ฌ์ค์ ์๊ธด ๋ฌธ์ ์๋ค. 2. Error: Nest can't resolve dependencies of ERROR [ExceptionHandler] Nest can't resolve dependencies of the SuperService (?). Please make sure that the argument UserDAL at index [0] is available in the SuperModule context. Potential solutions:..
server) ํธ๋์ด๋ ์ฃฝ์ด์ ๊ฐ์ฃฝ์ ๋จ๊ธฐ๊ณ , ๊ฐ๋ฐ์๋ ์ฃฝ์ด์ ๋ก๊ทธ๋ฅผ ๋จ๊ธด๋ค.
Feature ๋ก๊ทธ๋ ๋ญ์ง? ์ผ์ง, ๊ธฐ๋ก, ๊ธฐ๋กํ๋ค - ๋ค์ด๋ฒ ์ฌ์ โ ‘๋ก๊ทธ’(Log)๋ ์ปดํจํฐ๋ ์๋ฒ(Server) ๋ฑ์์ ์ ์ (User)์ ํ๋ ์ด ์ ๋ณด๋ฅผ ์๊ฐ์ ๋ฐ๋ผ ๋จ๊ธฐ๋ ๊ธฐ๋ก์ ๋ปํ๋ค. - ๋ค์ด๋ฒ ๊ฒ์ ์ฉ์ด ์ฌ์ ๋ก๊ทธ๋ ์ธ์ ์ด๋ค ์ ์ ๊ฐ ์ด๋ค ํ๋์ ํ๋๊ฐ ๋จ๊ธฐ๋๊ฒ ๋ก๊ทธ๋ค. console.log( ... )๋ ๋ก๊ทธ๋ผ ํ ์ ์๋ค. ์ด์ฐ๋์๋ ์๋ฒ๊ฐ ์ด๋ค ํ์๋ฅผ ๊ธฐ๋กํ๋ ๊ฒ์ด๊ธฐ ๋๋ฌธ์ด๋ค. ํํ๋ค ์ฐ๋ฆฌ๊ฐ ๋งํ๋ '๋ก๊ทธ ์ฐ์ด๋ด'๋ ๋๋ฒ๊น ์ฑํฅ์ด ๊ฐํ ๋ก๊ทธ์ ํด๋นํ๋ค. ๋ก๊ทธ๊ฐ ์ ํ์ํ ๊น? ์ค๋ฅ๋ฅผ ์ถ์ ํ๋๋ฐ ํฐ ๋์์ ์ค๋ค. ํต๊ณ์ฉ ๋ฐ์ดํฐ๋ก ํ์ฉํ ์ ์๋ค. ๋๋ฒ๊น ์ฉ์ผ๋ก ํ์ฉํ ์ ์๋ค. ๊ฐ๋จํ๊ฒ ๋ฐ์ดํฐ๋ฅผ ์ ์ฅํ ์ ์๋ค. ๋ก๊ทธ๋ ์ด๋ค ๊ฐ๋ฐ์ด๋ ์ ๋ง ์ค์ํ ๋ฐ์ดํฐ์ด๋ค. ์๊ฐํ๊ณ ์ถ์ง๋ ์์ง๋ง ํนํ ๋ก๊ทธ..