티스토리 뷰
[next.js] typeorm 사용시 Critical dependency: the request of a dependency is an expression / module not found: Can't resolve 'X' in with new Next.js project 에러
실전압축코딩 2023. 7. 19. 13:24
next.js에서 서버 컴포넌트에서 typeorm을 사용한 db접속을 구현 하고 있었다.
db 접속, query 실행등은 정상적으로 작동했으나. 엄청난 수의 "Critical dependency: the request of a dependency is an expression" 에러 메시지가 발생했다... 보아하니 typeorm 패키지의 종속성 문제인듯 하였다.
애꿎은 package.json만 여러번 만지던중 typeorm github에서 이미 해당 issue가 report된 것을 확인하였다!
https://github.com/typeorm/typeorm/issues/10047
Plenty of `Module not found: Can't resolve 'X' in` with new Next.js project · Issue #10047 · typeorm/typeorm
Issue description I've created a new brand Next.js project and I'm getting loads of warnings of modules that can't be found Expected Behavior Should be able to load and use typeorm without warnings...
github.com
해결 법은 간단하다.
next.config.js에
const path = require("path");
/** @type {import('next').NextConfig} */
const nextConfig = {
experimental: {
serverComponentsExternalPackages: ["typeorm"],
},
};
module.exports = nextConfig;
를 넣어주면 된다.
서버 컴포넌트의 외부 패키지를 강제로 잡아 주는 것 같다.
을 해주는 녀석이란다.
https://nextjs.org/docs/app/api-reference/next-config-js/serverComponentsExternalPackages
next.config.js Options: serverComponentsExternalPackages | Next.js
Using App Router Features available in /app
nextjs.org
serverComponentsExternalPackages는 Server Components bundling시, 혹은 node.js에서 require 함수를 사용시 opt-out specific dependencies를 설정해 주는 거라고 한다. 이 의미는 서버 구성요소로 사용할 외부 패키지를 typeorm으로 지정 해준다는 의미 이다.
'프론트엔드' 카테고리의 다른 글
[React.js 3D 에니메이션 만들기(3)] Leva 라이브러리를 사용해 조명 설정하기 (0) | 2024.12.01 |
---|---|
[React.js 3D 에니메이션 만들기(2)] 3D text geometry 생성 및 조명 설정 with react three fiber (1) | 2024.11.20 |
[React.js 3D 에니메이션 만들기(1)] generator(제네레이터) 를 활용해 에니메이션 시퀸스 만들기! with react three fiber/ framer-motion / react three rapier (0) | 2024.11.19 |
React 컴포넌트 Npm에 배포하기 (with TS) (0) | 2023.10.30 |
javascript 물음표 문법 (? , ??) (0) | 2022.07.22 |
- Total
- Today
- Yesterday
- 394. decode string javascript
- react fiber 3d
- eslint
- react 3d animation
- attempted import error: bvh_struct_definitions' is not exported from './gpu/bvhshaderglsl.js' (imported as 'bvhshaderglsl').
- react glsl
- vue
- 394. decode string js
- react 3d
- vue3
- 394 decode string
- Vue.js
- react 3d text
- typescript gsls
- react three fiber
- ts glsl
- [leetcode] 394. decode string
- react 3d 에니메이션
- three.js leva
- next.js import glsl
- [leetcode] 394. decode string js
- webpack glsl
- react three fiber leva
- react vue
- react ref reative
- react leva
- vue ref
- vue reactive
- leva
- vue react
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |