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'

// });

相关推荐
似水明俊德4 小时前
02-C#.Net-反射-面试题
开发语言·面试·职场和发展·c#·.net
Thera7775 小时前
C++ 高性能时间轮定时器:从单例设计到 Linux timerfd 深度优化
linux·开发语言·c++
炘爚6 小时前
C语言(文件操作)
c语言·开发语言
阿蒙Amon6 小时前
C#常用类库-详解SerialPort
开发语言·c#
凸头6 小时前
CompletableFuture 与 Future 对比与实战示例
java·开发语言
wuqingshun3141596 小时前
线程安全需要保证几个基本特征
java·开发语言·jvm
Moksha2626 小时前
5G、VoNR基本概念
开发语言·5g·php
jzlhll1236 小时前
kotlin Flow first() last()总结
开发语言·前端·kotlin
W.D.小糊涂6 小时前
gpu服务器安装windows+ubuntu24.04双系统
c语言·开发语言·数据库
用头发抵命7 小时前
Vue 3 中优雅地集成 Video.js 播放器:从组件封装到功能定制
开发语言·javascript·ecmascript