Closed
Description
Describe the bug
Next.js app build is failing with this error:
8:30:27 AM: ────────────────────────────────────────────────────────────────
8:30:27 AM: Plugin "@netlify/plugin-nextjs" failed
8:30:27 AM: ────────────────────────────────────────────────────────────────
8:30:27 AM:
8:30:27 AM: Error message
8:30:27 AM: Error: Error loading your next.config.js.
8:30:27 AM: Cannot find module '@next/bundle-analyzer'
8:30:27 AM: Require stack:
8:30:27 AM: - /opt/build/repo/frontend/next.config.js
8:30:27 AM: - /opt/build/repo/frontend/node_modules/next/dist/next-server/server/config.js
8:30:27 AM: - /opt/build/repo/frontend/.netlify/plugins/node_modules/@netlify/plugin-nextjs/helpers/getNextConfig.js
8:30:27 AM: - /opt/build/repo/frontend/.netlify/plugins/node_modules/@netlify/plugin-nextjs/index.js
8:30:27 AM: - /opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/src/plugins/child/logic.js
8:30:27 AM: - /opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/src/plugins/child/load.js
8:30:27 AM: - /opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/src/plugins/child/main.js
next.config.js
const hostname = new URL(process.env.WORDPRESS_URL).hostname;
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
});
module.exports = withBundleAnalyzer({
target: 'serverless',
webpack: config => {
config.module.rules.push({
test: /\.svg$/,
use: ['@svgr/webpack', 'url-loader'],
});
return config;
},
images: {
domains: [hostname],
},
});
netlify.toml
[build]
base = "frontend/"
command = "yarn build"
publish = ".next"
[[plugins]]
package = "@netlify/plugin-nextjs"
Versions
- next@10.2.3
- @netlify/plugin-nextjs@3.4.0
The last successful build happened 5/26 with these versions:
- next@10.2.3
- @netlify/build@11.22.0
- @netlify/plugin-nextjs@3.3.1
The first failed build happened 6/1 with these versions:
- next@10.2.3
- @netlify/build@11.29.2
- @netlify/plugin-nextjs@3.3.1
I tried to deploy the last successful build from 5/26 today and it failed with the same error with these versions:
- next@10.2.3
- @netlify/build@11.31.1
- @netlify/plugin-nextjs@3.4.0
I think the only thing that changed between the last successful deploy and when I tried to redeploy it are the @netlify/build
and @netlify/plugin-nextjs
versions.