Next.js 13 module not found 오류

버건디·2023년 2월 21일
0

Next.js

목록 보기
27/52

Next.js 13에서 unsplash api 를 사용하는 도중에 api를 호출하니까 모듈을 찾을 수 없다는 오류가 나왔다.

UNSPLASH_ACCESS_KEY의 타입을 지정을 안해주어서 나는 에러였다.

next-env.d.ts 파일에서 따로 인터페이스를 지정해주니 해결되었다.

- next-env.d.ts 파일

/// <reference types="next" />
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
declare namespace NodeJS {
  interface ProcessEnv {
    UNSPLASH_ACCESS_KEY: string;
  }
}

필요한 환경변수들은 여기서 선언해주면 될 것 같다.

profile
https://brgndy.me/ 로 옮기는 중입니다 :)

0개의 댓글