Next.js [cannot use import statement outside a module] Error Fix!

라이브러리 외부에 있는 js 파일을 import 하려고 시도할 때 나는 오류 입니다.

yarn add next-transpile-modules
// next.config.js
const withTM = require("next-transpile-modules")([
    "drei",
    "three",
    "postprocessing",
    "<라이브러리>"
]) // pass the modules you would like to see transpiled

module.exports = withTM()