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'

// });

相关推荐
是苏浙23 分钟前
零基础入门C语言之C语言实现数据结构之栈
c语言·开发语言·数据结构
后端小张28 分钟前
【JAVA 进阶】SpringBoot 事务深度解析:从理论到实践的完整指南
java·开发语言·spring boot·后端·spring·spring cloud·事务
荔枝吖34 分钟前
html2canvas+pdfjs 打印html
前端·javascript·html
y***54881 小时前
C++在游戏引擎中的开发
开发语言·c++·游戏引擎
郝学胜-神的一滴1 小时前
Python高级编程技术深度解析与实战指南
开发语言·python·程序人生·个人开发
起名时在学Aiifox1 小时前
深入解析 Electron 打包中的 EPERM: operation not permitted 错误
前端·javascript·electron
charlie1145141911 小时前
使用 Poetry + VS Code 创建你的第一个 Flask 工程
开发语言·笔记·后端·python·学习·flask·教程
Codeking__1 小时前
查缺补漏c语言——c标准字符串函数
c语言·开发语言
铅笔小新z1 小时前
【C++】从理论到实践:类和对象完全指南(中)
开发语言·c++
千疑千寻~1 小时前
【C++】std::move与std::forward函数的区别
开发语言·c++