Cannot find module ‘@next/bundle-analyzer‘

28.85 npm notice

28.99

28.99 > nextjs-15-starter-shadcn@1.0.0 build

28.99 > next build

28.99

29.49 ⨯ Failed to load next.config.js, see more info here https://nextjs.org/docs/messages/next-config-error

29.50

29.50 > Build error occurred

29.50 [Error: Cannot find module '@next/bundle-analyzer'

29.50 Require stack:

29.50 - /app/next.config.js] {

29.50 code: 'MODULE_NOT_FOUND',

29.50 requireStack: [Array]

29.50 }


Dockerfile:37


36 | # ENV NEXT_TELEMETRY_DISABLED=1

37 | >>> RUN \

38 | >>> if [ -f yarn.lock ]; then yarn --frozen-lockfile; \

39 | >>> elif [ -f package-lock.json ]; then npm ci --legacy-peer-deps; \

40 | >>> elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm i --frozen-lockfile; \

41 | >>> else echo "Lockfile not found." && exit 1; \

42 | >>> fi && \

43 | >>> if [ -f yarn.lock ]; then yarn run build; \

44 | >>> elif [ -f package-lock.json ]; then npm run build; \

45 | >>> elif [ -f pnpm-lock.yaml ]; then pnpm run build; \

46 | >>> else echo "Build command not found." && exit 1; \

47 | >>> fi

48 | # RUN \


ERROR: failed to build: failed to solve: process "/bin/sh -c if [ -f yarn.lock ]; then yarn --frozen-lockfile; elif [ -f package-lock.json ]; then npm ci --legacy-peer-deps; elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm i --frozen-lockfile; else echo \"Lockfile not found.\" && exit 1; fi && if [ -f yarn.lock ]; then yarn run build; elif [ -f package-lock.json ]; then npm run build; elif [ -f pnpm-lock.yaml ]; then pnpm run build; else echo \"Build command not found.\" && exit 1; fi" did not complete successfully: exit code: 1

删掉或者注解以下内容next.config.js

// module.exports = withBundleAnalyzer(nextConfig);

// const initializeBundleAnalyzer = require('@next/bundle-analyzer');

// // https://www.npmjs.com/package/@next/bundle-analyzer

// const withBundleAnalyzer = initializeBundleAnalyzer({

// enabled: process.env.BUNDLE_ANALYZER_ENABLED === 'true'

// });

相关推荐
蜡笔小马5 小时前
10.Boost.Geometry R-tree 空间索引详解
开发语言·c++·算法·r-tree
IOsetting5 小时前
金山云主机添加开机路由
运维·服务器·开发语言·网络·php
Hilaku5 小时前
不要在简历上写精通 Vue3?来自面试官的真实劝退
前端·javascript·vue.js
三小河5 小时前
前端视角详解 Agent Skill
前端·javascript·后端
林开落L5 小时前
从零开始学习Protobuf(C++实战版)
开发语言·c++·学习·protobuffer·结构化数据序列化机制
牛奔5 小时前
Go 是如何做抢占式调度的?
开发语言·后端·golang
颜酱5 小时前
二叉树遍历思维实战
javascript·后端·算法
鹏多多5 小时前
移动端H5项目,还需要react-fastclick解决300ms点击延迟吗?
前端·javascript·react.js
符哥20085 小时前
C++ 进阶知识点整理
java·开发语言·jvm
小猪咪piggy5 小时前
【Python】(4) 列表和元组
开发语言·python