✅
npm run buildでoutフォルダが作成されない時の対処(Next.js)
結論
next.config.mjsを以下のように編集する。デフォルトでは上のコードのようになっているため、ビルドコマンドを実行してもoutフォルダ(静的ページ)が作成されない。
next.config.mjs(修正前)
/** @type {import('next').NextConfig} */
const nextConfig = {};
export default nextConfig;
next.config.mjs(修正後)
/** @type {import('next').NextConfig} */
const nextConfig = {
output: 'export',
};
export default nextConfig;
まとめ
公式のドキュメントにはあったのですが、記事がなかったため作成しました。ここで詰まった人の役に立てばと思います。
参考サイト
Discussion