Frontend ๊ฐœ๋ฐœ์ž - hyo.loui

Project: ๐Ÿšฉcodefolio - toast ui Editor(codeSyntaxHighlightPlugin) ์ ์šฉ ์ค‘ ์—๋Ÿฌ ๋…ธํŠธ ๋ณธ๋ฌธ

Project

Project: ๐Ÿšฉcodefolio - toast ui Editor(codeSyntaxHighlightPlugin) ์ ์šฉ ์ค‘ ์—๋Ÿฌ ๋…ธํŠธ

hyo.loui 2023. 2. 22. 02:26

๐ŸŽฏ๋ชฉ์  :

Next ๊ฐœ๋ฐœ ํ™˜๊ฒฝ devDependencies ์ดํ•ดํ•˜๊ณ  ๊ธฐ๋ก ๋‚จ๊ธฐ๊ธฐ

 

๐Ÿคข ์˜ค๋ฅ˜ ํ•ด๊ฒฐ :

  • ๋ชจ๋“ˆ ์„ค์น˜ ํ›„ ์ƒ๊ธฐ๋Š” ํƒ€์ž… ์—๋Ÿฌ, import not found

1. Vercel Deployment Status Building Error

 

์šฐ๋ฆฌ ํ”„๋กœ์ ํŠธ๋Š” vercel์„ ์‚ฌ์šฉํ•˜์—ฌ deploy๋ฅผ ํ•œ๋‹ค.

์ฒซ init์„ ํ•œ ํ›„, vercel ์— ๊นƒํ—ˆ๋ธŒ๊ฐ€ ์—ฐ๋™์ด ๋˜๋ฉด

 

์นœ์ ˆํ•˜๊ฒŒ๋„ vercel์€ ์ž๋™์œผ๋กœ commit์— ๋Œ€ํ•œ ๋ณ€๋™์„ ์ธ์‹ํ•˜๊ณ 

ํ•ด๋‹น ๋‚ด์šฉ์œผ๋กœ build๋ฅผ ํ•ด์„œ done ์ด ๋˜๋Š”์ง€์˜ ์—ฌ๋ถ€๋ฅผ ์•Œ๋ ค์ค€๋‹ค.

 

ํ•˜์ง€๋งŒ ์˜ค๋Š˜ ์ปค๋ฐ‹์—์„œ building ์—๋Ÿฌ๊ฐ€ ๋‚ฌ๋Š”๋ฐ,

import๋ฅผ ํ•˜๋Š” ์ปดํฌ๋„ŒํŠธ๋Š” 2๊ฐœ ์˜€์œผ๋‚˜ 1๊ฐœ์˜ ์ปดํฌ๋„ŒํŠธ์—๋งŒ ์—๋Ÿฌ๊ฐ€ ๋‚˜์„œ

์™œ ๊ทธ๋Ÿฐ์ง€ ์ดํ•ด๊ฐ€ ์•ˆ๋˜์—ˆ๋‹ค..

 

์„œ์นญ ํ›„ typescript ๋นŒ๋”ฉ์ด ๋˜์ง€ ์•Š๋Š” ๋ฌธ์ œ์˜€๊ณ 

 

Type error: Could not find a declaration file for module 'prismjs'. '/vercel/path0/node_modules/prismjs/prism.js' implicitly has an 'any' type.


์œ„ ๊ฐ™์€ ์—๋Ÿฌ๋ฅผ ๋งŒ๋“ค์—ˆ๋‹ค

 


+ ์˜ค๋ฅ˜ : ์ฒซ๋ฒˆ์งธ ์‹œ๋„ ๋ฐฉ๋ฒ•

 

์œ„ ์—๋Ÿฌ์— ๋‚˜์™€์žˆ๋Š” ๋ฐฉ๋ฒ•๋Œ€๋กœ ์‹œ๋„๋ฅผ ํ–ˆ๋‹ค.

์šฐ๋ฆฌ๋Š” ํŒจํ‚ค์ง€ ๋งค๋‹ˆ์ €๋กœ yarn์„ ์‚ฌ์šฉํ•˜๊ธฐ ๋•Œ๋ฌธ์—

 

yarn add @type/prismjs

๋ช…๋ น์–ด๋ฅผ ์ž…๋ ฅํ•ด package.json ์— ์ถ”๊ฐ€๋œ ๊ฒƒ์„ ํ™•์ธ ํ–ˆ์œผ๋‚˜

 

'AS-IS'

๋ชจ๋“ˆ 'prismjs'์— ๋Œ€ํ•œ ์„ ์–ธ ํŒŒ์ผ์„ ์ฐพ์„ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.

๋ผ๋Š” ๋ฉ”์„ธ์ง€์™€ ํ•จ๊ป˜ ์ธ์‹ํ•˜์ง€ ๋ชปํ–ˆ๋‹ค..

 


+ ์˜ค๋ฅ˜ : ๋‘๋ฒˆ์งธ ์‹œ๋„ ๋ฐฉ๋ฒ•

tsconfig.json ํŒŒ์ผ์—

๊ฒฝ๋กœ ์„ค์ •์„ ํ•ด์ฃผ๋ฉด ๋ฌธ์ œ๊ฐ€ ํ•ด๊ฒฐ๋ ๊นŒ?

 

๋ผ๋Š” ์ƒ๊ฐ์—

{
  "compilerOptions": {
    "typeRoots" : ["./@types", "./node_modules/@types"]
  },
}

ํŒŒ์ผ์— ์œ„ ๊ตฌ๋ฌธ์„ ์ถ”๊ฐ€ํ–ˆ๋‹ค.

 

ํ•˜์ง€๋งŒ ์•„๋ฌด๋Ÿฐ ์ผ๋„ ์ผ์–ด๋‚˜์ง€ ์•Š์•˜๊ณ ,

๋ฌธ์ œ ์ธ์‹์„ ํ–ˆ๋‹ค..

 


+ ์˜ค๋ฅ˜ : ์„ธ๋ฒˆ์งธ ์‹œ๋„ ๋ฐฉ๋ฒ•

๋ฌธ์ œ๋Š” package.json ์ด์˜€๋‹ค.

 

next๋Š” dev ํ™˜๊ฒฝ์—์„œ ์‹คํ–‰๋˜๋ฉฐ,

typescript๋Š” ์ปดํŒŒ์ผ ์ „์˜ ์ƒํƒœ์ด๊ธฐ ๋•Œ๋ฌธ์—

 

"dependencies": {
    "prismjs": "^1.29.0"
  },

dependencies ์— ์žˆ๋Š” ํŒจํ‚ค์ง€๋ฅผ

 

"devDependencies": {
    "@types/prismjs": "^1.26.0"
    }

devDependencies ๋กœ ์ด๋™ํ•ด์ฃผ์–ด์•ผ ์ธ์‹ํ•  ์ˆ˜ ์žˆ๋Š” ์ƒํƒœ๊ฐ€ ๋œ๋‹ค.

 

'AS-IS'

 

'TO-BE'

 


 

 ์ตœ์ข… ์ •๋ฆฌ 

  1. next๋Š” dev ํ™˜๊ฒฝ์—์„œ ๊ฐœ๋ฐœ ํ•˜๊ณ  ์žˆ๋‹ค๋Š” ๊ฒƒ์„ ํ•ญ์ƒ ์ธ์ง€ํ•˜์ž.
  2. devDependencies์— ์†ํ•œ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋Š” ๋‹ค์šด๋กœ๋“œ ๋Œ€์ƒ์— ํฌํ•จ๋˜์ง€ ์•Š๊ณ  ๊ฐœ๋ฐœํ™˜๊ฒฝ, ๋นŒ๋“œ์‹œ ์‚ฌ์šฉ๋œ๋‹ค.