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'

// });

相关推荐
君顾19 小时前
上海24小时自助健身房系统开发实战指南:从架构设计到落地部署
java·开发语言·健身房
香菜TTT10 小时前
大模型上下文协议(MCP):AI 应用的“USB-C”接口技术
开发语言·人工智能·经验分享
aramae10 小时前
模拟实现strlen()函数 (C语言)
c语言·开发语言·后端
jimy111 小时前
readelf 查看“派生类”的vtable符号
开发语言·c++
ctlover12 小时前
排序与查找算法详解
开发语言·python
YYYing.12 小时前
【C++进阶系列 (七)】C++ RTTI 深度剖析:从 typeid 到 dynamic_cast 的底层之旅
开发语言·c++·c/c++·rtti
nvvas13 小时前
Java 入门(四):数组——数据的集合管理
java·开发语言
默_笙13 小时前
🚋 从流水线到地铁网:为什么复杂 AI 都要拆成多 Agent(上)——LangGraph 基础入门
前端·javascript
ID346107442014 小时前
【课程设计】基于Spring Boot+Vue的游戏账号租赁系统的设计与实现-计算机毕设 附源码50345
javascript·vue.js·spring boot·python·node.js·php·课程设计