Gatsby๋ฅผ 2.17.7์์ 2.18.4๋ก ์ ๋ฐ์ดํธ ํ ํ ๋ชจ๋ ์ข ๋ฅ์ gatsby ๋ช ๋ น์ ์คํํ๋ฉด ์ค๋ฅ๊ฐ ๋ฐ์ํฉ๋๋ค. ํ์ง๋ง ๋ง ๊ทธ๋๋ก ๋ฌธ๋งฅ์ด ์์ต๋๋ค.
> gatsby clean
The above error occurred in the <StoreStateProvider> component:
in StoreStateProvider
in App
React will try to recreate this component tree from scratch using the error boundary you provided, App.
Warning: App: Error boundaries should implement getDerivedStateFromError(). In that method, return a state update to display an error message or fallback UI.
> gatsby build
The above error occurred in the <StoreStateProvider> component:
...
๋ถํํ๋ ๋ค๋ฅธ ๋ช
๋ น๊ณผ ๋์ผํ StateStoreProvider
์ค๋ฅ์ ํจ๊ป ์ถฉ๋ํ๋ฏ๋ก gatsby info --clipboard
์คํํ ์ ์์ต๋๋ค. Gatsby ๋ฒ์ ์ ๋ค์ ๋๋๋ฆฌ๊ณ ์ด ๋ช
๋ น์ ์คํํ์ต๋๋ค. ์๋ ์ถ๋ ฅ์ Gatsby ๋ฒ์ ์ ์ฌ๋ฐ๋ฅด์ง ์์ต๋๋ค .
System:
OS: Windows 10
CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
Binaries:
npm: 6.9.0 - C:\Program Files\nodejs\npm.CMD
Languages:
Python: 2.7.16 - C:\Python27\python.EXE
Browsers:
Edge: 44.18362.267.0
npmPackages:
gatsby: ^2.17.7 => 2.17.7
gatsby-source-apiserver: ^2.1.4 => 2.1.4
2.17.10์์ 2.18.4๋ก ์ ๋ฐ์ดํธ ํ ํ์๋ ๋์ผํ ๋ฌธ์ ๊ฐ ๋ฐ์ํฉ๋๋ค.
์ ๊ณ ํด์ฃผ์ ์ ๊ฐ์ฌํฉ๋๋ค!
gatsby-cli๋ฅผ ์ ๊ทธ๋ ์ด๋ ํ ์๋ ์์ต๋๊น? ์ด๊ฒ์ด ๋์์ด๋์ง ์๋๋ค๋ฉด, ์ฐ๋ฆฌ์๊ฒ ๋ณต์ ์ ์ฅ์๋ฅผ ์ ๊ณตํด ์ฃผ์๋ฉด ์ ๋ง ๋์์ด ๋ ๊ฒ์ ๋๋ค.
๊ฐ์ฌํฉ๋๋ค! : purple_heart :
์ค์ ๋ก ์ ์ธ๊ณ์ ์ผ๋ก CLI๊ฐ ์ค์น๋์ด ์์ง ์์ต๋๋ค. ์ด ํ๋ก์ ํธ๋ ๋ก์ปฌ์ ์ค์น๋ Gatsby ๋ฒ์ ์ ์ฌ์ฉํ์ฌ gatsby <command>
๋ฅผ ์ฐจ๋ก๋ก ์คํํ๋ npm run <command>
๋ช
๋ น์ ์์กดํฉ๋๋ค.
์ด ํจํด์ ์ฌ์ฉํ๋ ์ฌ๋๋ค์ ์ ์ธ๊ณ์ ์ผ๋ก ์์กดํ๋ ๊ธฐ๊ณ๋ฅผ ๋ฒ๋ฆด ํ์๊ฐ ์์ต๋๋ค. (์ ์ฌ์ ์ผ๋ก ๋ค๋ฅธ ๋ฒ์ ์ด ํ์ํ ์ฌ๋ฌ ํ๋ก์ ํธ์์ ์์ ํ๋ฉด ์ถ์ ํด์ง ์ ์์)
์ค๋ ์ด๋ฐ ๋น์ทํ ๋ฌธ์ ๊ฐ ์์๋๋ฐ ๋ฐ์, react-dom ๋ฐ gatsby๋ฅผ ์ ๋ฐ์ดํธํ๊ณ node_modules ๋ฐ package-lock.json์ ์ง์ฐ๋ ๊ฒ์ด ํจ๊ณผ์ ์ด์์ต๋๋ค. ๋ง์ง๋ง์ผ๋ก npm install์ ๋ค์ ์คํํ๊ณ ๋ชจ๋ ๊ฒ์ด ์ ์๋ํ์ต๋๋ค.
react
๋ฐ react-dom
๋ฐ Gatsby ์
๋ฐ์ดํธ๊ฐ ์๋ํ๋ ๊ฒ ๊ฐ์ต๋๋ค. Gatsby๊ฐ ํธํ๋๋ ์ฌ๋ฐ๋ฅธ React ๋ฒ์ ์ ๋์ดํด์ผํ์ง ์์ต๋๊น?
์ด์ ๋๋ deps๊ฐ ์ค๋ก ์ค์น ๋ ๋ ๊ฐ์ธ ๋น ๋น๋ / ๊ฐ๋ฐ์ด ์ ์๋ํ๋์ง ์์ ๋ด๊ธฐ ์ํด ๋ฐ๋์ ์ ๋ณด๋๋ค.
React์ Gatsby ๊ฐ์ ํธํ์ฑ ๋ฌธ์ ์ ๊ด๋ จ์ด์๋ ๊ฒ ๊ฐ์ต๋๋ค. ์ ๊ธ ํ์ผ์์ด ์ฒ์๋ถํฐ ์ข ์์ฑ์ ์ค์นํ๋ ๊ฒฝ์ฐ ํจํค์ง ๊ด๋ฆฌ์ (yarn ๋๋ npm)๋ ์ต์ ๋ฒ์ (package.json์ ์ ํ์ ์ํด ํ์ฉ๋จ) ๋ง ๊ฐ์ ธ์ต๋๋ค.
์ ๊ฒฝ์ฐ์๋ ๋ฐ์ ๋ฒ์ ์ด package-lock.json
์ ์ ๊ฒจ ์์๊ธฐ ๋๋ฌธ์ ์๋ก ์ค์นํ๋๋ผ๋ Gatsby์ ํจ๊ป ์
๋ฐ์ดํธ๋์ง ์์์ต๋๋ค.
๋์ผํ ๋ฌธ์ ๊ฐ ๋ฐ์ํฉ๋๋ค. ๋๋ gatsby, gatsby-cli, react ๋ฐ react-dom์ ์ฑ๊ณต์ผ๋ก ์ ๋ฐ์ดํธํ์ต๋๋ค. ํ์คํ ํด๊ฒฐ์ฑ ์ด ์์ต๋๊น?
ํธ์ง : ๋๋ gatsby์ gatsby-cli๋ฅผ ์ ๊ฑฐํ๊ณ ๊ฐ๋ณ์ ์ผ๋ก ๋ค์ ์ค์นํ์ผ๋ฉฐ ์์ ํ ๊ฒ ๊ฐ์ต๋๋ค. ์ด์ํ ๋ฌธ์ .
์ด ๋ฌธ์ ๊ฐ ๋ฐ์ํ์ต๋๋ค. ๋ ๊ฐ์ง ๋ฒ์ ์ ๋ฐ์์ด ์ค์น๋์ด ์๊ธฐ ๋๋ฌธ์
๋๋ค. npm ls react
๋ฅผ ์คํํ์ฌ ํ์ธํ์ธ์. ๋ด package.json์ ์ง์ ๋ ๋ฐ์ ๋ฒ์ ์ด ์์ผ๋ฉฐ gatsby / gatsby-cli 2.18.5์ ๋ค๋ฅธ ๋ฒ์ ์ ๋ฐ์์ด์๋ ๊ฒ์ฒ๋ผ ๋ณด์
๋๋ค.
์ด ํ์ด์ง๋ฅผ ํตํด ๋ฌธ์ ๋ฅผ ์๊ฒ๋์์ต๋๋ค.
์ฌ์ ํ ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๋ ์ค ...
๋ฌธ์ ๋ฅผ ํด๊ฒฐํ์ต๋๋ค! npm์ ์ฌ์ฉํ์ฌ ์ ๊ฑฐํ ๋ค์ react
, react-dom
๋ฐ gatsby
๋ฅผ (๋ค์) ์ค์นํ์ต๋๋ค. ๋๋ ๊ทธ ์ ํํ ์์๋ก ๊ทธ๊ฒ์ํ๋ค (๋๋ ์์๊ฐ ์ค์ ํ ๊ฒ์ด๋ผ๊ณ ๋ฏฟ์ง ์๋๋ค.
npm ls react
๋ ๋ ๊ฐ์ง ๋ฒ์ ์ ํ์ํ์ง๋ง ๋์ผํ๋ฉฐ "์ค๋ณต ๋จ"์ผ๋ก ํ์๋ฉ๋๋ค.
[email protected] <redacted the filepath>
โโโฌ [email protected]
โ โโโฌ [email protected]
โ โโโ [email protected] deduped
โโโ [email protected]
์ง๊ธ์ ์ฐจ๋จ์ด ํด์ ๋์ด ์์ง๋ง ์ฌ์ ํ ์ฐ๋ ค ์ฌํญ์ด ์์ต๋๋ค.
1) ๋ ๊ฐ์ง ๋ฒ์ ์ ๋ฐ์์ด ์ฌ์ ํ ์กด์ฌํฉ๋๊น? (์ ๋ชจ๋ฅด๊ฒ ์ด) ์ง๊ธ์ ๊ฐ์ ๋ฒ์ ์ด๋ผ๋
2) ํฅํ ๊ฐ์ธ ๋น ์
๋ฐ์ดํธ๋ก ์ธํด์ด ๋ฌธ์ ๊ฐ ๋ค์ ๋ฐ์ํฉ๋๊น?
๋ต์ ์์ง๋ง ๊ฐ์ธ ๋น ํ์ด ๊ณ ๋ คํ ์ฐ๋ ค๋ฅผ ํ๋ช ํฉ๋๋ค.
npm ls
๋ ํ๋ก์ ํธ์ ์ข
์์ฑ ํธ๋ฆฌ๋ฅผ ์ดํดํ๋ ๋ฐ ๋์์ด๋๋ ๋๊ตฌ ์ผ ๋ฟ์ด๋ผ๊ณ ํ์ ํฉ๋๋ค. ๋ฆฌ ์กํธ ๋ณต์ฌ๋ณธ์ด ํ๋๋ง ์ค์น๋์์ ๊ฒ์
๋๋ค. node_modules
ํด๋๋ก ๋ค์ด๊ฐ์ ...
๊ฐ์ธ ๋น๋ฅผ ์ ๋ฐ์ดํธ ํ ํ์๋ ๋์ผํ ๋ฌธ์ ๊ฐ ๋ฐ์ํ์ต๋๋ค. ์ด์ ๋ฒ์ ์ธ "gatsby": "^ 2.13.73"์ผ๋ก ๋ค์ด ๊ทธ๋ ์ด๋ํ๋๋ฐ ์ฌ๋ฌ ๋ฒ์ ์ด ๋์ ์์ง๋ง ๋ฌธ์ ๊ฐ ํด๊ฒฐ๋์์ต๋๋ค.
๋ฌธ์ ๋ฅผ ํด๊ฒฐํ์ต๋๋ค! npm์ ์ฌ์ฉํ์ฌ ์ ๊ฑฐํ ๋ค์
react
,react-dom
๋ฐgatsby
๋ฅผ (๋ค์) ์ค์นํ์ต๋๋ค. ๋๋ ๊ทธ ์ ํํ ์์๋ก ๊ทธ๊ฒ์ํ๋ค (๋๋ ์์๊ฐ ์ค์ ํ ๊ฒ์ด๋ผ๊ณ ๋ฏฟ์ง ์๋๋ค.
npm ls react
๋ ๋ ๊ฐ์ง ๋ฒ์ ์ ํ์ํ์ง๋ง ๋์ผํ๋ฉฐ "์ค๋ณต ๋จ"์ผ๋ก ํ์๋ฉ๋๋ค.[email protected] <redacted the filepath> โโโฌ [email protected] โ โโโฌ [email protected] โ โโโ [email protected] deduped โโโ [email protected]
์ด๊ฒ์ ๋๋ฅผ ์ํด ์ผํ์ต๋๋ค. ๊ฐ์ฌ!
๋ฌธ์ ๋ฅผ ํด๊ฒฐํ์ต๋๋ค! npm์ ์ฌ์ฉํ์ฌ ์ ๊ฑฐํ ๋ค์
react
,react-dom
๋ฐgatsby
๋ฅผ (๋ค์) ์ค์นํ์ต๋๋ค. ๋๋ ๊ทธ ์ ํํ ์์๋ก ๊ทธ๊ฒ์ํ๋ค (๋๋ ์์๊ฐ ์ค์ ํ ๊ฒ์ด๋ผ๊ณ ๋ฏฟ์ง ์๋๋ค.
npm ls react
๋ ๋ ๊ฐ์ง ๋ฒ์ ์ ํ์ํ์ง๋ง ๋์ผํ๋ฉฐ "์ค๋ณต ๋จ"์ผ๋ก ํ์๋ฉ๋๋ค.[email protected] <redacted the filepath> โโโฌ [email protected] โ โโโฌ [email protected] โ โโโ [email protected] deduped โโโ [email protected]
์์ ๋ง์ฐฌ๊ฐ์ง๋ก์ด ์๋ฃจ์ ์ ์ ์๊ฒ๋ ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ์ต๋๋ค.
react ๋ฐ react-dom์ 16.12.0์ผ๋ก ์ ๊ทธ๋ ์ด๋ ํ ๋ค์ gatsby๋ฅผ 2.18.7๋ก ์ ๊ทธ๋ ์ด๋ํ์ฌ ๋ฌธ์ ๋ฅผ ์ฑ๊ณต์ ์ผ๋ก ํด๊ฒฐํ์ต๋๋ค.
์ค์ : react, react-dom ๋ฐ gatsby๋ฅผ ์ ๊ทธ๋ ์ด๋ ํ ํ "gatsby clean"์ ์คํํด์ผํฉ๋๋ค.
@clarmso๊ฐ ์ ์ํ๋๋ก gatsby๋ฅผ 2.18.7๋ก ์ ๊ทธ๋ ์ด๋ํ๋ฉด ๋์๊ฒ ํธ๋ฆญ์ด ์๊ฒผ ์ต๋๋ค (๋ฐ์์ 16.12.0 ์).
๋ํ ์ด์ ๋์ผํ ๋ฌธ์ ๊ฐ ์์ต๋๋ค. ๋ฐ์ ๋ฐ ๊ฐ์ธ ๋น๋ฅผ ์ ๋ฐ์ดํธํ์ง๋ง ์ฌ์ ํ ๋์ผํ ๋ฌธ์ ๊ฐ ์์ต๋๋ค. ๋ํ ์ ๋ฐ์ดํธ ํ ์ฒญ์๋ฅผ ์๋ํ์ง๋ง ๋ฌธ์ ๊ฐ ์ง์๋ฉ๋๋ค.
"๊ฐ์ธ ๋น": "^ 2.18.11"
"๋ฐ์": "^ 16.12.0"
"react-dom": "^ 16.12.0"
๋ํ ์ด์ ๋์ผํ ๋ฌธ์ ๊ฐ ์์ต๋๋ค. ๋ฐ์ ๋ฐ ๊ฐ์ธ ๋น๋ฅผ ์ ๋ฐ์ดํธํ์ง๋ง ์ฌ์ ํ ๋์ผํ ๋ฌธ์ ๊ฐ ์์ต๋๋ค. ๋ํ ์ ๋ฐ์ดํธ ํ ์ฒญ์๋ฅผ ์๋ํ์ง๋ง ๋ฌธ์ ๊ฐ ์ง์๋ฉ๋๋ค.
"๊ฐ์ธ ๋น": "^ 2.18.11"
"๋ฐ์": "^ 16.12.0"
"react-dom": "^ 16.12.0"
์ ๋ ๋ง์ฐฌ๊ฐ์ง์ ๋๋ค. yestarday๊ฐ ์ ์๋ ํ ๋๊น์ง
๋ฌธ์ ๋ฅผ ํด๊ฒฐํ์ต๋๋ค! npm์ ์ฌ์ฉํ์ฌ ์ ๊ฑฐํ ๋ค์
react
,react-dom
๋ฐgatsby
๋ฅผ (๋ค์) ์ค์นํ์ต๋๋ค. ๋๋ ๊ทธ ์ ํํ ์์๋ก ๊ทธ๊ฒ์ํ๋ค (๋๋ ์์๊ฐ ์ค์ ํ ๊ฒ์ด๋ผ๊ณ ๋ฏฟ์ง ์๋๋ค.
npm ls react
๋ ๋ ๊ฐ์ง ๋ฒ์ ์ ํ์ํ์ง๋ง ๋์ผํ๋ฉฐ "์ค๋ณต ๋จ"์ผ๋ก ํ์๋ฉ๋๋ค.[email protected] <redacted the filepath> โโโฌ [email protected] โ โโโฌ [email protected] โ โโโ [email protected] deduped โโโ [email protected]
์ด๊ฒ์ ๋์๊ฒ๋ ํจ๊ณผ์ ์ด์์ต๋๋ค. ์๊ตฌ์ ์ธ ์์ ์ ์ํด ์์ ์ค์ ๋๊น?
์ด๋ฌํ ์ ๋ฐ์ดํธ๋ก ์ธํด ์ด์ StoreStateProvider์ ๋ํ ๋ ์ด์ํ ๊ฒฝ๊ณ ์ Contentful์ ์์์ ํญ๋ชฉ์ด ์กด์ฌํ๋๋ผ๋ null๋ก ๋์์ต๋๋ค.
๋ฌด์จ ์ผ์ด ์ผ์ด๋๊ณ ์๋์ง ์ ๋ชจ๋ฅด๊ฒ ์ง๋ง ์ง๊ธ์ ์ง์ ์ ๋ณด๊ดํด์ผํฉ๋๋ค.
๋ํ ์ด์ ๋์ผํ ๋ฌธ์ ๊ฐ ์์ต๋๋ค. ๋ฐ์ ๋ฐ ๊ฐ์ธ ๋น๋ฅผ ์ ๋ฐ์ดํธํ์ง๋ง ์ฌ์ ํ ๋์ผํ ๋ฌธ์ ๊ฐ ์์ต๋๋ค. ๋ํ ์ ๋ฐ์ดํธ ํ ์ฒญ์๋ฅผ ์๋ํ์ง๋ง ๋ฌธ์ ๊ฐ ์ง์๋ฉ๋๋ค.
"๊ฐ์ธ ๋น": "^ 2.18.11"
"๋ฐ์": "^ 16.12.0"
"react-dom": "^ 16.12.0"
node_modules ํด๋ ๋ฐ package-lock.json ํ์ผ์ ์ ๊ฑฐํ์ต๋๋ค. npm ์ค์น๋ฅผ ์คํํ๊ณ ๋ค์ ๋ชจ๋ ์ข์ต๋๋ค.
๋ด ๊ฒฝํ์ ์์ ์๊ฒฌ์ ์กฐํฉ์ด์์ต๋๋ค. node_modules ํด๋๋ฅผ ์ญ์ ํ๊ณ gatsby ํ๋ฌ๊ทธ์ธ์ด ์์๊ธฐ ๋๋ฌธ์ npm์ด ์๋ํ์ง ์์ต๋๋ค. ์์ฌ ์ค์น๊ฐ ๋ง์นจ๋ด ์์ ํ์ต๋๋ค.
react
, react-dom
๋ฐ gatsby
์ (๋ฅผ) ๋ค์ ์ค์นํ์ฌ์ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ์ต๋๋ค. (https://github.com/gatsbyjs/gatsby/issues/19827#issuecomment-559898690)
์ ์
react v16.11.0
react-dom v16.11.0
gatsby v2.17.11
ํ
react v16.12.0
react-dom v16.12.0
gatsby v2.18.12
๋ฌธ์ ๋ฅผ ํด๊ฒฐํ์ต๋๋ค! npm์ ์ฌ์ฉํ์ฌ ์ ๊ฑฐํ ๋ค์
react
,react-dom
๋ฐgatsby
๋ฅผ (๋ค์) ์ค์นํ์ต๋๋ค. ๋๋ ๊ทธ ์ ํํ ์์๋ก ๊ทธ๊ฒ์ํ๋ค (๋๋ ์์๊ฐ ์ค์ ํ ๊ฒ์ด๋ผ๊ณ ๋ฏฟ์ง ์๋๋ค.
npm ls react
๋ ๋ ๊ฐ์ง ๋ฒ์ ์ ํ์ํ์ง๋ง ๋์ผํ๋ฉฐ "์ค๋ณต ๋จ"์ผ๋ก ํ์๋ฉ๋๋ค.[email protected] <redacted the filepath> โโโฌ [email protected] โ โโโฌ [email protected] โ โโโ [email protected] deduped โโโ [email protected]
๊ฐ์ฌํฉ๋๋ค. ์ ์๊ฒ ํจ๊ณผ์ ์ด์์ต๋๋ค ๐พ
๊ฐ์ธ์ ์ผ๋ก node_modules
ํด๋์ package-lock.json
์ ์ญ์ ํด์ผํฉ๋๋ค.
๊ทธ๋ฐ ๋ค์ react
, react-dom
๋ฐ gatsby
์
๊ทธ๋ ์ด๋ํฉ๋๋ค.
"react": "^16.12.0",
"react-dom": "^16.12.0",
"gatsby": "^2.18.17",
์
๋ฐ์ดํธํ๋ ๊ฒ์ ์์ง ๋ง์ธ์ gatsby-cli
์ต์ ๋ฒ์ ๋ฐ ์ด์ํ๋ gatsby clean
๊ทธ ํ gatsby develop
๊ฐ ๋งค๋ ฅ์ฒ๋ผ ์๋ํฉ๋๋ค!
๊ธฐ๋ณธ ๊ฐ์ธ ๋น ๋ก๊ฑฐ๋ฅผ ์ฌ์ฉํ ๋๋ง ๋ฌธ์ ๊ฐ ๋ฐ์ํ๋ค๋ ๊ฒ์ ์์์ต๋๋ค. ์ฌ์ฉ๋ ํน์ ๋ก๊ฑฐ๋ GATSBY_LOGGER ํ๋ก์ธ์ค env ๋ฅผ ํตํด ์ ์ด๋ฉ๋๋ค. ์๋ฅผ ๋ค์ด json ๋ก๊ฑฐ๋ฅผ ์ฌ์ฉํ์ฌ ๊ธฐ๋ณธ ๋ก๊ฑฐ๊ฐ ๋ณ๊ฒฝ๋ ๊ฒฝ์ฐ์ด ๋ฌธ์ ๋ ์ฌํ ํ ์ ์์ต๋๋ค.
export GATSBY_LOGGER=["json"]
npm i && npm run start
yurnalist
/ json
์ ํํ๋ฉด Gatsby ๋ก๊ฑฐ ์์ ๋ฌธ์ ๊ฐ ํด๊ฒฐ๋ฉ๋๋ค.
export GATSBY_LOGGER=["yurnalist"]
์ค๋ ์ด์ ํ๋ก์ ํธ์์ gatsby develop
๋ฅผ ์คํํ ๋์ด ๋ฌธ์ ๊ฐ ๋ฐ์ํ์ต๋๋ค (์ต๊ทผ gatsby develop์ ์คํ ํ ๊ฒ์ ๊ฐ์์ด์์ต๋๋ค).
์์ (๋งค์ฐ ๋์์ด๋๋!) ์ ์์ ์กฐํฉํ์ฌ ์์ ํ์ต๋๋ค.
์ด๊ฒ์ด ์๋ํ๋์ง ํ์ธํ ์ ์์ต๋๋ค.
gatsby clean
-๋ฌธ์ ๊ฐ ํด๊ฒฐ๋์๋์ง ํ์ธํ๊ธฐ ์ํด ์์ํ์ต๋๋ค.node_modules
์ญ์ npm install
์ด ์์ ์์ ํด๊ฒฐ๋์ง ์์์ผ๋ฏ๋ก์ด๋ฅผ ์ํํ๊ธฐ ์ํด ์กฐ์ธ์ ๋ฐ๋์ต๋๋ค.
npm uninstall react react-dom gatsby
npm install react react-dom gatsby
์ด๊ฒ์ ์๋ฒฝํ๊ฒ ์๋ํ์ต๋๋ค.
package-lock.json ์ญ์
์ญ์ ๋ node_modules
npm i ์คํ
๋๋ฅผ ์ํด ์ผํ๋ค : D
๋ฌธ์ ๋ฅผ ํด๊ฒฐํ์ต๋๋ค! npm์ ์ฌ์ฉํ์ฌ ์ ๊ฑฐํ ๋ค์
react
,react-dom
๋ฐgatsby
๋ฅผ (๋ค์) ์ค์นํ์ต๋๋ค. ๋๋ ๊ทธ ์ ํํ ์์๋ก ๊ทธ๊ฒ์ํ๋ค (๋๋ ์์๊ฐ ์ค์ ํ ๊ฒ์ด๋ผ๊ณ ๋ฏฟ์ง ์๋๋ค.
npm ls react
๋ ๋ ๊ฐ์ง ๋ฒ์ ์ ํ์ํ์ง๋ง ๋์ผํ๋ฉฐ "์ค๋ณต ๋จ"์ผ๋ก ํ์๋ฉ๋๋ค.[email protected] <redacted the filepath> โโโฌ [email protected] โ โโโฌ [email protected] โ โโโ [email protected] deduped โโโ [email protected]
์๋ฃจ์
์ ๊ฐ์ฌ๋๋ฆฝ๋๋ค! ์ด๊ฒ์ ๋๋ฅผ์ํ ์ฃผ์ ์ฐจ๋จ์ ์์ต๋๋ค. ์ฒ์์๋ ์๋ํ์ง ์์์ง๋ง gatsby-cli
๋ ๋ค์ ์ค์นํ์ต๋๋ค. ๊ทธ ํ์๋ ์ ์๋ํ์ต๋๋ค.
๊ธฐ์
Gatsby๋ฅผ 2.17.7์์ 2.18.4๋ก ์ ๋ฐ์ดํธ ํ ํ ๋ชจ๋ ์ข ๋ฅ์ gatsby ๋ช ๋ น์ ์คํํ๋ฉด ์ค๋ฅ๊ฐ ๋ฐ์ํฉ๋๋ค. ํ์ง๋ง ๋ง ๊ทธ๋๋ก ๋ฌธ๋งฅ์ด ์์ต๋๋ค.
> gatsby clean The above error occurred in the <StoreStateProvider> component: in StoreStateProvider in App React will try to recreate this component tree from scratch using the error boundary you provided, App. Warning: App: Error boundaries should implement getDerivedStateFromError(). In that method, return a state update to display an error message or fallback UI.
> gatsby build The above error occurred in the <StoreStateProvider> component: ...
ํ๊ฒฝ
๋ถํํ๋ ๋ค๋ฅธ ๋ช ๋ น๊ณผ ๋์ผํ
StateStoreProvider
์ค๋ฅ์ ํจ๊ป ์ถฉ๋ํ๋ฏ๋กgatsby info --clipboard
์คํํ ์ ์์ต๋๋ค. Gatsby ๋ฒ์ ์ ๋ค์ ๋๋๋ฆฌ๊ณ ์ด ๋ช ๋ น์ ์คํํ์ต๋๋ค. ์๋ ์ถ๋ ฅ์ Gatsby ๋ฒ์ ์ ์ฌ๋ฐ๋ฅด์ง ์์ต๋๋ค .System: OS: Windows 10 CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz Binaries: npm: 6.9.0 - C:\Program Files\nodejs\npm.CMD Languages: Python: 2.7.16 - C:\Python27\python.EXE Browsers: Edge: 44.18362.267.0 npmPackages: gatsby: ^2.17.7 => 2.17.7 gatsby-source-apiserver: ^2.1.4 => 2.1.4
๋๋ ๊ฐ์ ๋ฌธ์ ์ ์ง๋ฉดํ๋ค! ๋๋ฅผ ๋๋ ์๋ฃจ์
์ yarn์ ์ค์นํ๊ณ package.json์ ํด์๋ ํ๋๋ฅผ ์ถ๊ฐํ๋ ๊ฒ์
๋๋ค.
https://yarnpkg.com/lang/en/docs/selective-version-resolutions/
์ด ์ค๋ฅ๋ gatsby-cli
๋ด๋ถ์ ์ผ๋ก react
์ ink
๋ฅผ ์ฌ์ฉํ์ฌ ์ ์ธํฐํ์ด์ค๋ฅผ ๋ ๋๋ง ํ ๊ฒฐ๊ณผ์
๋๋ค. ํ๋ก์ ํธ์ react
๋ฒ์ ๊ณผ gatsby
ํ์ํ ๋ฒ์ ๊ฐ์ ๋ฒ์ ๊ด๋ฆฌ๊ฐ ์๋ชป๋์ด์ด ๋ฌธ์ ๊ฐ ๋ฐ์ํ์ต๋๋ค.
์ ์ธ๊ณ์ ์ผ๋ก gatsby-cli
์ค์น (๊ถ์ฅ)ํ๋ฉด ๋ด๊ฐ ์๋ ํ ์ด๋ฌํ ๋ฌธ์ ๋ฅผ ๋ฐฉ์ง ํ ์ ์์ต๋๋ค. ๊ทธ๋ผ์๋ ๋ถ๊ตฌํ๊ณ ์ด๊ฒ๊ณผ ๊ด๋ จํ์ฌ gatsby
์์ ์์ ํด์ผ ํ ๊ฒ์ด ์๊ธฐ ๋๋ฌธ์ ์ด๊ฒ์ ๋ซ์ต๋๋ค.
์ฌ๋ฌ๋ถ ๋ชจ๋ ๊ฐ์ฌํฉ๋๋ค! ๐
์ด์ ๋๋ deps๊ฐ ์ค๋ก ์ค์น ๋ ๋ ๊ฐ์ธ ๋น ๋น๋ / ๊ฐ๋ฐ์ด ์ ์๋ํ๋์ง ์์ ๋ด๊ธฐ ์ํด ๋ฐ๋์ ์ ๋ณด๋๋ค.
ํจ๊ณผ์ ์ผ๋ก ์ค์ ์ฌ์ฉํ๋ฉด ๋๋ ๋ฌธ์ ๊ฐ ํด๊ฒฐ๋์์ต๋๋ค.
npm update
๋ง ์คํํ๋ฉด ๋ฌธ์ ๊ฐ ํด๊ฒฐ๋์์ต๋๋ค.
gatsby-cli๋ฅผ ์ ์ญ์ผ๋ก ์ค์น (๊ถ์ฅ)ํ๋ฉด ๋ด๊ฐ ์๋ ํ ์ด๋ฌํ ๋ฌธ์ ๋ฅผ ๋ฐฉ์ง ํ ์ ์์ต๋๋ค. ๊ทธ๋ผ์๋ ๋ถ๊ตฌํ๊ณ ์ด๊ฒ๊ณผ ๊ด๋ จํ์ฌ ๊ฐ์ธ ๋น์์ ์์ ํด์ผ ํ ๊ฒ์ด ์๊ธฐ ๋๋ฌธ์ ์ด๊ฒ์ ๋ซ์ต๋๋ค.
์ด๊ฒ์ ๋๋ฅผ ์ํด ์๋ํ์ง ์์์ต๋๋ค. ์์์ ์ธ๊ธ ํ๋๋ก ๋ก๊ฑฐ๋ฅผ yurnalist
๋๋ json
๋ก ์ ํํ์ต๋๋ค. public
, .cache
๋ฐ node_modules
ํด๋๋ ์ ๊ฑฐํ์ต๋๋ค.
๊ฐ์ธ ๋น ๋ฒ์ ์ ์ถ๋ ฅ :
gatsby -v
Gatsby CLI version: 2.8.27
Gatsby version: 2.18.25
๊ถ๊ธํ ๊ฒฝ์ฐ ๋ด ์ข ์์ฑ์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
"dependencies": {
"@emotion/core": "^10.0.27",
"@emotion/styled": "^10.0.27",
"gatsby": "^2.18.25",
"gatsby-image": "^2.2.39",
"gatsby-plugin-emotion": "^4.1.21",
"gatsby-plugin-google-analytics": "^2.1.33",
"gatsby-plugin-manifest": "^2.2.37",
"gatsby-plugin-netlify": "^2.1.31",
"gatsby-plugin-offline": "^3.0.32",
"gatsby-plugin-react-helmet": "^3.1.21",
"gatsby-plugin-sharp": "^2.3.13",
"gatsby-plugin-web-font-loader": "^1.0.4",
"gatsby-remark-images": "^3.1.42",
"gatsby-remark-prismjs": "^3.3.30",
"gatsby-remark-reading-time": "^1.1.0",
"gatsby-source-filesystem": "^2.1.46",
"gatsby-transformer-remark": "^2.6.48",
"gatsby-transformer-sharp": "^2.3.13",
"prism-themes": "^1.3.0",
"prismjs": "^1.19.0",
"prop-types": "^15.7.2",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-helmet": "^5.2.1",
"typeface-karla": "0.0.72"
},
๋ด๊ฐ๋ฐ์ ์ค๋ฅ๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
gatsby develop
ERROR
The above error occurred in the <StoreStateProvider> component:
in StoreStateProvider
in App
React will try to recreate this component tree from scratch using the error boundary you provided, App.
ERROR
Warning: App: Error boundaries should implement getDerivedStateFromError(). In that method, return a state update to display an error message or fallback UI.
ERROR
UNHANDLED REJECTION Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
See https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem.
Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
See https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem.
- react.development.js:1590 resolveDispatcher
[project]/[gatsby]/[react]/cjs/react.development.js:1590:13
- react.development.js:1618 useState
[project]/[gatsby]/[react]/cjs/react.development.js:1618:20
- context.js:17 StoreStateProvider
[project]/[gatsby]/[gatsby-cli]/lib/reporter/loggers/ink/context.js:17:41
- react-reconciler.development.js:6036 renderWithHooks
[project]/[react-reconciler]/cjs/react-reconciler.development.js:6036:18
- react-reconciler.development.js:8570 mountIndeterminateComponent
[project]/[react-reconciler]/cjs/react-reconciler.development.js:8570:13
- react-reconciler.development.js:9938 beginWork$1
[project]/[react-reconciler]/cjs/react-reconciler.development.js:9938:16
- react-reconciler.development.js:11563 Object.invokeGuardedCallbackImpl
[project]/[react-reconciler]/cjs/react-reconciler.development.js:11563:10
- react-reconciler.development.js:11740 invokeGuardedCallback
[project]/[react-reconciler]/cjs/react-reconciler.development.js:11740:31
- react-reconciler.development.js:15778 beginWork$$1
[project]/[react-reconciler]/cjs/react-reconciler.development.js:15778:7
- react-reconciler.development.js:14696 performUnitOfWork
[project]/[react-reconciler]/cjs/react-reconciler.development.js:14696:12
์ ์ด์ ์กด์ฌํด์๋ ์๋๋ ๋ฌธ์ ๋ฅผ ์ฐพ๋ ํ์ฌ์ ์ธ ๊ฐ๋ฐ์์๊ฒ :
-node_modules ํด๋ ์ ๊ฑฐ
-package.lock.json ์ญ์
-npm i ์คํ
๋ณต์ ์ผ์ด์ค๋ฅผ ์์ ๋ฃ์ ํ :
NPM์์ ์ฌ์ฉ์ ์ ์ ๋ฒ์ ์ค์น์ ํจ๊ป์ด ์ฌ๊ฑด์์ ์จ ๊ฒ์ผ๋ก ๋ณด์ธ๋ค react
์์ ์ค์น๊ฐ node_modules
ํ๋ฉด์, gatsby-cli
๋ฐ์์ ๋ฒ์ ์ ์ค์น๋ฉ๋๋ค node_modules/gatsby/node_modules
.
ink
๊ฐ node_modules
์ค์น๋๋ ๊ฒ์ผ๋ก ๋ณด์ด๋ฏ๋ก ink
react
๊ฐ์ ธ ์ค๊ธฐ๋ gatsby-cli
๊ฐ์ ธ ์ค๊ธฐ์ ๋ค๋ฅธ ๊ฐ์ ธ ์ค๊ธฐ๋ฅผ ์ฌ์ฉํ๋ฏ๋ก ๋ค์๊ณผ ๊ฐ์ ๊ฒฝ์ฐ๊ฐ ๋ฐ์ํฉ๋๋ค.
- ๋์ผํ ์ฑ์ ๋ ์ด์์ React ์ฌ๋ณธ์ด์์ ์ ์์ต๋๋ค.
์ด ๋ฌธ์ ๋ฅผ ๋๋ฒ๊ทธํ๊ณ ์์ ํ๋ ๋ฐฉ๋ฒ์ ๋ํ ํ์ https://fb.me/react-invalid-hook-call ์ ์ฐธ์กฐ
๊ทธ๋ฆฌ๊ณ https://reactjs.org/warnings/invalid-hook-call-warning.html#duplicate -react๋ ์ด๊ฒ์ ๊ฝค ์ ์ค๋ช
ํ์ง๋ง ๊ฑฐ๊ธฐ์์๋ ์ ์ ( yarn resolutions
์ ์ฌ์ฉํ๋ ๊ฒ์ ๋ฌธ์ ์ด๊ธฐ ๋๋ฌธ์ ์๋ํ์ง ์์ต๋๋ค) npm
๊ฐ node_modules
๊ตฌ์กฐ๋ฅผ ๊ฒฐ์ ํ๋ ๊ฒ์ฒ๋ผ ๋ณด์ด๋ฉฐ ์ค์ด ์๋)
์ง๊ธ ๋ด ๋ง์์ ๋ ์ค๋ฅด๋ ์ ์ผํ ํด๊ฒฐ์ฑ
์ Node.js ๋ชจ๋ ํด์๋๋ฅผ ์ฌ์ ์ํ๊ณ react
์ gatsby-cli
์ ์ ๋ ๊ฒ์ผ๋ก ํ๋ ์ฝ๋ฉํ๋ ๊ฒ์
๋๋ค. ๊ทธ๋ ๊ฒํด๋ ๊ด์ฐฎ์ ์ ์์ต๋๋ค (PnP๊ฐ ์ ์ด๋ yarn v1์์ ๊ตฌํ๋๋ ๋ฐฉ์์
๋๋ค).
๋ช ๊ฐ์ง ๋ ์๊ฐํ ํ-๋ค๋ฅธ ์ต์
์ createRequireFromPath
์์ gatsby-core-utils
createRequireFromPath
๋ฅผ ์ฌ์ฉํ๋ ๊ฒ์
๋๋ค (https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-core-utils/README .md # createrequirefrompath)๋ฅผ ์ฌ์ฉํ๊ณ gatsby-cli์์ ink
์ ๋์ผํ ๋ฒ์ ์ ๋ฐ์์๋ก๋ํ๋ ๋ฐ ์ฌ์ฉํฉ๋๋ค (์ด๋ ํดํค๊ฐ ํจ์ฌ ์ ๊ณ Node.js ๋ชจ๋ ํ์ธ ์ค๋ฒ๋ก๋๋ก ์ธํด ๋ฐ์ํ ์์๋ ์ ์ฌ์ ๋ฌธ์ ์ ๊ฐ๋ฅ์ฑ์ด ์ ์ต๋๋ค). .
์ ์ผํ ๋ฌธ์ ๋ ํ์ฌ ink
๊ตฌ์ฑ ์์ ( ink-spinner
๋ ํ์ฌ ์ฌ์ฉ์ค์ธ ๊ตฌ์ฑ ์์ ์ค ํ๋์)๋ฅผ ์ฌ์ฉํ๊ณ ink
๊ณผ ๋ค๋ฅธ ๋๋ ํฐ๋ฆฌ์ ์ค์น๋๋ ๊ฒฝ์ฐ์๋ง ๋ฐ์ํฉ๋๋ค.
ink-spinner
๋ด๋ถ์์ gatsby-cli
๊ณต๊ธํ๊ณ ํ์ฌ ๊ตฌ์ฑ ์์๋ฅผ ํจํค์ง๋ก ์ฌ์ฉํ์ง ์๋๋กํ์ฌ ์ ์ฌ์ ์ธ ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ ์ ์์ต๋๋ค (๋ฐ ๋ชจ๋ ๊ณต๊ธ ์
์ฒด).
--- ํธ์ง :
์์์์ฃผ์ํด์ผํฉ๋๋ค. ink
์๋ node >= 16.8.0
์ด ํ์ํ๋ฏ๋ก gatsby-cli
์์ react >= 16.8.1
์ดํ์ ๊ธฐ๋ฅ์ ์ฌ์ฉํ์ง ์๋๋กํด์ผํฉ๋๋ค.- ๋ ๋ง์ ์ฐ๊ตฌ๊ฐ ํ์ํ์ง๋ง ์ ๋งํฉ๋๋ค.
์
๋ฐ์ดํธ : createRequireFromPath
๊ฒฝ๋ก๋ฅผํ์ง ์์ต๋๋ค ์ผ ๋๋ฌธ์ npm
๊ทธ๋ฅ "์ ๋๋ก"ํด๊ฒฐํ ์ node_modules
๊ณ์ธต ๊ตฌ์กฐ๋ ์ฃผ์ด์ง dependencies
๋ฐ peerDependencies
์ ๊ณต : ink
๋ฐ gatsby-cli
.
"๋น ๋ฅธ"๋ณ๊ฒฝ ์ฌํญ์ react
๋ฒ์ ์๊ตฌ ์ฌํญ (https://github.com/gatsbyjs/gatsby/pull/21522)์ ๋ฎ์ถ์ด์ด ๋ฌธ์ ๊ฐ ๋ฐ์ํ ์๋๋ฆฌ์ค์ ์์ ์ค์ด๋ ๊ฒ์
๋๋ค.
๊ทธ๋ฌ๋ ์ด๊ฒ์ด ์์ ํ ๊ณ ์ณ์ง์ง๋ ์์ต๋๋ค. ์ด๋ฅผ ์ํด npm
node_modules
๊ณ์ธต ๊ตฌ์กฐ๋ฅผ ์ ๋๋ก ์์ฑํ์ง ๋ชปํ๋ ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๊ธฐ ์ํด react
๋ฒ์ ์ gatsby-cli
์ ๋ฒ๋ค๋ก ๋ฌถ์ ๊ฒ์
๋๋ค (๋๋ Node.js ๋ชจ๋ ํ์ธ์ ์ฌ์ ์ํ์ง๋ง ์ด๊ฒ์ ์์์น ๋ชปํ ๊ฒฐ๊ณผ๋ฅผ ์ด๋ํ ์์๋ ํดํน์ด๋ฏ๋ก ๋ค๋ฅธ ํด๊ฒฐ์ฑ
์ด ์์ผ๋ฉด ํผํ๊ณ ์ถ์ต๋๋ค.)
๋ ๋ค๋ฅธ ์
๋ฐ์ดํธ - ์ฐ๋ฆฌ๋ ์ผ๋ถ ์
๋ฐ์ดํธํ๋ค gatsby
๊ฐ ์ถํ๋์๋ค - ๊ทธ๊ฒ์ ์ํฅ์ ์ ํ ํ๋ก์ ํธ๋ฅผ [email protected]
-ํ์ง๋ง ์ฌ์ ํ / ๋ค์ ์ญ์ ํด์ผ ํ ์๋ package-lock.json
.
๊ทธ๋๋ ๋ฌธ์ ๊ฐ ํด๊ฒฐ๋์ง ์์ผ๋ฉด react
/ react-dom
์ด (๊ฐ) package.json
๊ณ ์ ๋์ด ์๊ณ ๋ฒ์ ์ด [email protected]
๋ณด๋ค ๋ฎ์ ์ ์์ต๋๋ค.- ์ฐ๋ฆฌ๊ฐ ์์ง ๊ทธ๊ฒ์ ๋ํด ์์ ์ ๊ฐ์ง๊ณ ์์ง ์์ง๋ง ๋ค์ ๋จ๊ณ๋ก ์กฐ์ฌํ๊ณ ์์ต๋๋ค - ๊ฐ๋ฅํ ํด๊ฒฐ ๋ฐฉ๋ฒ์ ์ฌ์ฉ yarn
๋์ npm
์ง๊ธ (ํ์ธ๋์ง ์์).
๋๊ตฐ๊ฐ๊ฐ ๊ธฐ์ ์ ์ธ ๊ฒ์ ๊ด์ฌ์ด ์๋ค๋ฉด ์ด๊ธฐ Pull Request์ ๋ํ ์๊ฒฌ์ ํ์ธ ํ์ญ์์ค -https://github.com/gatsbyjs/gatsby/pull/21508#issuecomment -586753917 ํ์ฌ ๊ณํ์ ์ผ๋ถ ๋ฒ ๋ค๋ฌ๋ฅผ ์ฌ์ฉํ๋ ๊ฒ์
๋๋ค (์๋ง microbundle
) ๋ฒ๋คํ๊ธฐ react
์์ gatsby-cli
๊ฐ ์ฌ์ฉํ๋ ค๊ณ ํ์ง ์๋๋ก react
์์ node_modules
๋ค๋ง์ด์์ ๊ฒ์ด๋ค gatsby-cli
์ง์ ํฌํจ)
๋๋ ์ด๋ฌํ ์ฝ๋ฉํธ๋ฅผ ๋ง์ด ์๋ํ์ง๋ง, ํ๋ก์ธ์ค์ ์ด๋ค ๋ถ๋ถ์๋ npm
๋ฅผ ์ฌ์ฉํ์ง ์์ ์ฌ๋์ผ๋ก์ ๋๋ ํน๋ณํ ์ ์๊ฒ ํจ๊ณผ๊ฐ์๋ ๊ฒ์ ์ธ ๊ฒ์ด๋ผ๊ณ ์๊ฐํ์ต๋๋ค.
๋ด ์ค์ :
Win10, .msi๋ฅผ ํตํด ์ค์น๋ Yarn, yarn global
๋ฅผ ํตํด Gatsby. ๋ชจ๋ Gatsby ํ๋ก์ ํธ์ yarn
์ฌ์ฉ.
๋ฌธ์ :
gatsby {command}
๋ StoreStateProvider
์ค๋ฅ๋ฅผ ์์ฑํ์ง๋ง npx gatsby {command}
๋ ์๋ํฉ๋๋ค.
ํด๊ฒฐ์ฑ :
.cache
๋ฐ /node_modules
์์ผ๋ฉด ์ญ์ ํฉ๋๋ค.react
๋ฐ react-dom
์ด (๊ฐ)์ด ๊ธ์ ์ฐ๋ ์์ ์์ "^16.13.0"
์
๋ฐ์ดํธ๋์๋์ง ํ์ธํฉ๋๋ค.yarn global remove gatsby gatsby-cli
๋ฅผ ์คํํ์ฌ ์์๋ CLI๋ฅผ ์ ๊ฑฐํฉ๋๋ค.yarn global add gatsby gatsby-cli
๋ฅผ ์คํํ์ฌ CLI๋ฅผ ๋ค์ ์ค์นํ์ญ์์ค.gatsby -v
๋๋ ๋ค๋ฅธ gatsby {command}
๋ฅผ ์คํํ๋ฉด ์๋ํฉ๋๋ค.์ฐ์ถ:
> gatsby -v
Gatsby CLI version: 2.9.0
Gatsby version: 2.19.23
ํ์ผ!
์ด ๋ฌธ์ ๋ ์กฐ์ฉํด์ก์ต๋๋ค. ๋ฌด์ ๋ฌด์ํ ์กฐ์ฉํจ. ๐ป
๋ง์ ๋ฌธ์ ๊ฐ ๋ฐ์ํ๋ฏ๋ก ํ์ฌ 30 ์ผ ๋์ ํ๋์ด ์์ผ๋ฉด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํฉ๋๋ค. ์ฌ๊ธฐ์ ๋ง์ง๋ง์ผ๋ก ์
๋ฐ์ดํธ ํ ์ง 20 ์ผ์ด ์ง๋ฌ์ต๋๋ค.
์ด ๋ฌธ์ ๋ฅผ ๋์ณค๊ฑฐ๋ ๊ณ์ ์ด๋ ค๊ณ ์ถ๋ค๋ฉด ์ฌ๊ธฐ์์ ๋ต์ฅ ํด์ฃผ์ธ์. ์ด ๋ฌธ์ ๋ฅผ ๊ณ์ ์ด์ด๋๊ธฐ ์ํด "๋ถ์คํ์ง ์์"์ด๋ผ๋ ๋ ์ด๋ธ์ ์ถ๊ฐ ํ ์๋ ์์ต๋๋ค.
์ด ๋ฌธ์ ๋ ๋ค๋ฅธ ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๋ ๊ฐ์ฅ ์ข์ ๋ฐฉ๋ฒ์ Pull Request๋ฅผ ์ฌ๋ ๊ฒ์
๋๋ค. PR ์ด๊ธฐ, ๋ฌธ์ ๋ถ๋ฅ ๋ฐ ๊ธฐ์ฌ์ ๋ํ ์์ธํ ์ ๋ณด๋ gatsby.dev/contribute ๋ฅผ ํ์ธํ์ญ์์ค!
Gatsby ์ปค๋ฎค๋ํฐ์ ์ผ์์ด๋์ด ์ฃผ์ ์ ๊ฐ์ฌํฉ๋๋ค! ๐ช๐
ํ๋์ด๋ณ๋ก ์์ง๋ง ๋ก์ ๊ฒ ๊ฐ์ง ์๋ค์
๋๋์ด ๊ฐ์ ๋ฌธ์ ๋ฅผ ๊ฒช๊ณ ์์๋๋ฐ, ๋ด๊ฐ ํ ์ผ์ json.lock์ ์ญ์ ํ๊ณ yarn ๋ช ๋ น์ ์คํํ์ฌ ์ข ์์ฑ์ ์ ๋ฐ์ดํธํ๋ ๊ฒ์ ๋๋ค. ๋ชจ๋ ๊ฒ์ด ์ ์์ ์ผ๋ก ์๋ํ๊ฒ๋์์ต๋๋ค.
"node_modules"ํด๋์ "package-lock.json"ํ์ผ์ ์ญ์ ํ ๋ค์ "npm install"๋ช ๋ น์ ์ญ์ ํ์ฌ ํด๊ฒฐ ํ ๊ฒ๊ณผ ๋์ผํ ๋ฌธ์ ๊ฐ ๋ฐ์ํ์ต๋๋ค.
ํ์ผ!
์ด ๋ฌธ์ ๋ ์กฐ์ฉํด์ก์ต๋๋ค. ๋ฌด์ ๋ฌด์ํ ์กฐ์ฉํจ. ๐ป
๋ง์ ๋ฌธ์ ๊ฐ ๋ฐ์ํ๋ฏ๋ก ํ์ฌ 30 ์ผ ๋์ ํ๋์ด ์์ผ๋ฉด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํฉ๋๋ค. ์ฌ๊ธฐ์ ๋ง์ง๋ง์ผ๋ก ์
๋ฐ์ดํธ ํ ์ง 20 ์ผ์ด ์ง๋ฌ์ต๋๋ค.
์ด ๋ฌธ์ ๋ฅผ ๋์ณค๊ฑฐ๋ ๊ณ์ ์ด๋ ค๊ณ ์ถ๋ค๋ฉด ์ฌ๊ธฐ์์ ๋ต์ฅ ํด์ฃผ์ธ์. ์ด ๋ฌธ์ ๋ฅผ ๊ณ์ ์ด์ด๋๊ธฐ ์ํด "๋ถ์คํ์ง ์์"์ด๋ผ๋ ๋ ์ด๋ธ์ ์ถ๊ฐ ํ ์๋ ์์ต๋๋ค.
์ด ๋ฌธ์ ๋ ๋ค๋ฅธ ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๋ ๊ฐ์ฅ ์ข์ ๋ฐฉ๋ฒ์ Pull Request๋ฅผ ์ฌ๋ ๊ฒ์
๋๋ค. PR ์ด๊ธฐ, ๋ฌธ์ ๋ถ๋ฅ ๋ฐ ๊ธฐ์ฌ์ ๋ํ ์์ธํ ์ ๋ณด๋ gatsby.dev/contribute ๋ฅผ ํ์ธํ์ญ์์ค!
Gatsby ์ปค๋ฎค๋ํฐ์ ์ผ์์ด๋์ด ์ฃผ์ ์ ๊ฐ์ฌํฉ๋๋ค! ๐ช๐
๋ ์๋ !
์ด ๋ฌธ์ ์ ๋ํด ๋ฌด์จ ์ผ์ด ์ผ์ด๋ ์ง 30 ์ผ์ด ์ง๋ฌ์ผ๋ฏ๋ก ์ฐ๋ฆฌ์ ์น์ ํ ์ด์ ๋ก๋ด (๋์ผ!)์ด ๋ฌธ์ ๋ซ์ ๊ฒ์
๋๋ค.
์ ๋ ๋ก๋ด ์ผ ๋ฟ์ด๋ฏ๋ก์ด ๋ฌธ์ ๋ฅผ ์ค์๋ก ์ข
๋ฃํ๋ค๋ฉด HUMAN_EMOTION_SORRY
์
๋๋ค. ์ด ๋ฌธ์ ๋ฅผ ๋ค์ ์ด๊ฑฐ ๋ ๋ค๋ฅธ ๊ฒ์ด ํ์ํ๋ฉด ์ ๋ฌธ์ ๋ฅผ ๋ง๋์ญ์์ค.
์ด ๋ฌธ์ ๋ ๋ค๋ฅธ ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๋ ๊ฐ์ฅ ์ข์ ๋ฐฉ๋ฒ์ Pull Request๋ฅผ ์ฌ๋ ๊ฒ์
๋๋ค. PR ์ด๊ธฐ, ๋ฌธ์ ๋ถ๋ฅ ๋ฐ ๊ธฐ์ฌ์ ๋ํ ์์ธํ ์ ๋ณด๋ gatsby.dev/contribute ๋ฅผ ํ์ธํ์ญ์์ค!
Gatsby ์ปค๋ฎค๋ํฐ์ ์ฐธ์ฌํด ์ฃผ์ ์ ๋ค์ ํ ๋ฒ ๊ฐ์ฌ๋๋ฆฝ๋๋ค! ๐ช๐
: slightly_frowning_face : ์ ๋ ์ฌ์ ํ yurnalist
์ ๊ธฐ๋ณธ ๋ก๊ฑฐ๋ก ์ฌ์ฉํ๊ณ ์์ต๋๋ค. ๋๋ ์ด๊ฒ์ด ์์ ๋์๋ค๋ ์
๋ฐ์ดํธ๋ฅผ ๋ณด์ง ๋ชปํ์ต๋๋ค.
์ ์ด์ ์กด์ฌํด์๋ ์๋๋ ๋ฌธ์ ๋ฅผ ์ฐพ๋ ํ์ฌ์ ์ธ ๊ฐ๋ฐ์์๊ฒ :
-node_modules ํด๋ ์ ๊ฑฐ
-package.lock.json ์ญ์
-npm i ์คํ
์ด๊ฒ์ ๋๋ฅผ ์ํด ์ผํ์ต๋๋ค ...
gatsby
(v 2.23.11)์ ์ ๊ฑฐํ๊ณ ๋ค์ ์ค์นํ๋ ๊ฒ์ด ์ ์๊ฒ ํจ๊ณผ์ ์ด์์ต๋๋ค.
์ค ์ค์น๋ฅผ ์ฌ์ฉํ์ญ์์ค.
๊ทธ๋์ ๋ด๊ฐ ํ ์ผ์ (์ง๊ธ๊น์ง ๋ชจ๋ ๊ฒ์ ์ฝ์ ํ) Gatsby 2.18.7์ package.json ํ์ผ์์ ๋ฒ์ ์ ๋ณ๊ฒฝํ๊ณ npm i
ํ์ต๋๋ค.
์ฌ์ ํ์ด ๋ฌธ์ ๊ฐ ๋ฐ์ํฉ๋๋ค.
$: gatsby -v
Gatsby CLI version: 2.12.66
Gatsby version: 2.23.12
์ฌํ ๋จ๊ณ :
gatsby new
๋ฅผ ์ฌ์ฉํ์ฌ ์ ํ๋ก์ ํธ ๋ง๋ค๊ธฐnpm i --save node-sass gatsby-plugin-sass
์ฌ์ฉํ์ฌ sass ์ค์นgatsby develop
๊ฒฐ๊ณผ
$ gatsby develop
ERROR
The above error occurred in the <StoreStateProvider> component:
in StoreStateProvider
in App
React will try to recreate this component tree from scratch using the error boundary you provided, App.
ERROR
Warning: App: Error boundaries should implement getDerivedStateFromError(). In that method, return a state update to display an error message or fallback UI.
ERROR
UNHANDLED REJECTION Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
See https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem.
Error: Invalid hook call. Hooks can only be called inside of the body of a fun ction component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as Reac t DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
See https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem.
- react.development.js:1465 resolveDispatcher
[bug]/[gatsby]/[react]/cjs/react.development.js:1465:13
- react.development.js:1496 useState
[bug]/[gatsby]/[react]/cjs/react.development.js:1496:20
- context.js:21 StoreStateProvider
[bug]/[gatsby]/[gatsby-cli]/lib/reporter/loggers/ink/context.js:21:49
- react-reconciler.development.js:6036 renderWithHooks
[bug]/[ink]/[react-reconciler]/cjs/react-reconciler.development.js:6036:18
- react-reconciler.development.js:8570 mountIndeterminateComponent
[bug]/[ink]/[react-reconciler]/cjs/react-reconciler.development.js:8570:13
- react-reconciler.development.js:9938 beginWork$1
[bug]/[ink]/[react-reconciler]/cjs/react-reconciler.development.js:9938:16
- react-reconciler.development.js:11563 Object.invokeGuardedCallbackImpl
[bug]/[ink]/[react-reconciler]/cjs/react-reconciler.development.js:11563:10
- react-reconciler.development.js:11740 invokeGuardedCallback
[bug]/[ink]/[react-reconciler]/cjs/react-reconciler.development.js:11740:31
- react-reconciler.development.js:15778 beginWork$$1
[bug]/[ink]/[react-reconciler]/cjs/react-reconciler.development.js:15778:7
- react-reconciler.development.js:14696 performUnitOfWork
[bug]/[ink]/[react-reconciler]/cjs/react-reconciler.development.js:14696:12
์์์ ์ค๋ช ํ๋๋ก ๋ค์์ ์ํํ์ฌ ์ง์นจ์ ๊ตฌํํ์ฌ์ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ์ต๋๋ค. โ๏ธ
๊ทธ๋์ ๋ด๊ฐ ํ ์ผ์ (์ง๊ธ๊น์ง ๋ชจ๋ ๊ฒ์ ์ฝ์ ํ) Gatsby 2.18.7์ package.json ํ์ผ์์ ๋ฒ์ ์ ๋ณ๊ฒฝํ๊ณ ์คํํ์ต๋๋ค.
npm i
ํจ๊ณผ๊ฐ ์์
.cache ๋ฐ node_modules ํด๋์ package-lock.json์ ์ ๊ฑฐํ ๋ค์ ๋ค์ ์ค์นํ๋ฉด ์ ์๊ฒ ํจ๊ณผ์ ์ด์์ต๋๋ค.
๋๋ ์ค์ ์ ๊ทธ๋ ์ด๋ํ๊ณ ๊ทธ๊ฒ์ ๋๋ฅผ ์ํด ์ผํ์ต๋๋ค.
node_modules
, npm ์บ์ ๋ฐ package-lock.json
ํ์ผ์ ์ ๊ฑฐํ๋ ๊ฒ์ ํ๋ฌ๊ทธ์ธ ๋๋ ์ข
์์ฑ์ด ์ถ๊ฐ ๋ ๋๋ง๋ค ์ฃผ์ ๋ณ๊ฒฝ ์ฌํญ์ ๋ํ ๋น์ค์ฉ์ ์ธ ์๋ฃจ์
์
๋๋ค.
๋ด ๊ฒฝ์ฐ์ ๊ทผ๋ณธ์ ์ธ ๋ฌธ์ ๋ gatsby new [path] [starter]
์ฌ์ฉํ์ฌ ํ๋ก๋น์ ๋ ๋ ์ ํ๋ก์ ํธ๊ฐ yarn
๊ฐ ์ค์น๋์ด ์๊ณ ์ฌ์ฉ ๊ฐ๋ฅํ ๊ฒฝ์ฐ ์ข
์์ฑ์ ๋ถํธ ์คํธ๋ฉํ๊ธฐ ์ํด ์์ ์ ์ผ๋ก yarn
๋ฅผ ์ฌ์ฉํ๋ค๋ ๊ฒ์
๋๋ค ( which yarn
๋ฐํ ๋น์ด ์์ง ์์ ๋ฌธ์์ด). npm
๋ฐ yarn
์ (๋) ์ํธ ๋ฐฐํ์ ์ธ ํจํค์ง ๊ด๋ฆฌ ์๋ฃจ์
์ด๊ธฐ ๋๋ฌธ์ npm
์ (๋ฅผ) ์ฌ์ฉํ์ฌ ํ๋ฌ๊ทธ์ธ / ์ข
์์ฑ์ ์ค์นํ๋ ค๋ ํ์ ์๋๋ ์์ ๊ฒ์ ๋ ๊ฒ์ฒ๋ผ ์ํธ ์ค๋ฅ์ ํจ๊ป ์คํจํฉ๋๋ค.
gatsby cli๊ฐ์ด๋ฅผ ์์ฒญํ๋ ๋ช
๋ น ์ค ์ต์
์์ด yarn
๋ฅผ ๊ธฐ๋ณธ๊ฐ์ผ๋ก ์ค์ ํ์ง ์๋ ๊ฒ์ด ์ข์ต๋๋ค. ๋๋ฅผ์ํ ํด๊ฒฐ์ฑ
์ yarn ์ npm
๋ง ์ฌ์ฉํ ์ ์๋๋กํ๋ ๊ฒ์ด ์์ต๋๋ค.
https://github.com/gatsbyjs/gatsby/pull/26887 ์ ๊ฑฐ (๋ณํฉ ์ด์ ๋ฐํ ์ค๋) react
์ ์ข
์์์ gatsby-cli
์ฐ๋ฆฌ๋ ํจํค์ง๋ฅผ ๊ฒ์ ํ ๋ ๋์ ํ๊ณ ๊ทธ๊ฒ์ ๋ฒ๋ค - ์ด๋ค์ด ์๋ฏธ๋ ๋ชจ๋ ์ข
๋ฅ์ ๋ฌธ์ ๋ฅผ ์ผ์ผํค๋ node_modules
์์ react
์ ์ด์ํ ์ฌ๋ฌ ๋ณต์ฌ๋ณธ์ด ์์ฑ๋์ง ์์์ผํ๋ค๋ ๊ฒ์
๋๋ค.
@ duchess-toffee https://github.com/gatsbyjs/gatsby/pull/26856 ํฅ๋ฏธ๋ก์ด ๊ฒ์ ์ฐพ์ ์ ์์ต๋๋ค (์์ง ๋ณํฉ / ์ถ์๋์ง ์์)- yarn
์์ npm
์๋ ๋ณต๊ท๋์ง๋ ์์ต๋๋ค. gatsby options set pm npm
๋ฅผ ์คํํ ์ ์์ต๋๋ค.
์ด ๋ฌธ์ ์ ๊ด๋ จ๋ ๊ฒ์ผ๋ก ๋ณด์ด๋ ๋ฌธ์ ๊ฐ ์์ต๋๋ค. # 26998
์ฌ์ฉ์ ์ ์ ์นํฉ ๊ตฌ์ฑ์ ์ฌ์ฉํ์ฌ react
ํด๊ฒฐ :
````js
// ํ์ผ : gatsby-node.js
const ๊ฒฝ๋ก = require ( 'path')
module.exports = {
onCreateWebpackConfig : ({์์
}) => {
actions.setWebpackConfig ({
ํด๊ฒฐ : {
๋ณ์นญ : {
'๋ฐ์': path.resolve (path.join (__ dirname, 'node_modules', 'react'))
}
}
})
}
}
````
json
// file: package.json
{
"dependencies": {
"@mdx-js/mdx": "^1.6.18",
"@mdx-js/react": "^1.6.18",
"gatsby": "^2.24.64",
"gatsby-plugin-layout": "^1.3.11",
"gatsby-plugin-mdx": "^1.2.40",
"gatsby-plugin-sass": "^2.3.12",
"gatsby-source-filesystem": "^2.3.30",
"gatsby-telemetry": "^1.3.35",
"node-sass": "^4.14.1",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-ionicons-v5": "^1.2.0",
"three": "^0.120.1"
}
}
์ด์ ๋ชจ๋ ๊ฒ์ด ์ํํ๊ฒ ์คํ๋ฉ๋๋ค.
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
๋ฌธ์ ๋ฅผ ํด๊ฒฐํ์ต๋๋ค! npm์ ์ฌ์ฉํ์ฌ ์ ๊ฑฐํ ๋ค์
react
,react-dom
๋ฐgatsby
๋ฅผ (๋ค์) ์ค์นํ์ต๋๋ค. ๋๋ ๊ทธ ์ ํํ ์์๋ก ๊ทธ๊ฒ์ํ๋ค (๋๋ ์์๊ฐ ์ค์ ํ ๊ฒ์ด๋ผ๊ณ ๋ฏฟ์ง ์๋๋ค.npm ls react
๋ ๋ ๊ฐ์ง ๋ฒ์ ์ ํ์ํ์ง๋ง ๋์ผํ๋ฉฐ "์ค๋ณต ๋จ"์ผ๋ก ํ์๋ฉ๋๋ค.