Skip to content

@netlify/plugin-nextjs fails with "Cannot find module" #384

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
clareoneill opened this issue Jun 3, 2021 · 2 comments
Closed

@netlify/plugin-nextjs fails with "Cannot find module" #384

clareoneill opened this issue Jun 3, 2021 · 2 comments
Labels
priority: high status: needs reproduction this issue needs to provide a repo that reproduces the bug described type: bug code to address defects in shipped code

Comments

@clareoneill
Copy link

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


The last successful build happened 5/26 with these versions:

The first failed build happened 6/1 with these versions:

I tried to deploy the last successful build from 5/26 today and it failed with the same error with these versions:

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.

@lindsaylevine lindsaylevine added priority: high type: bug code to address defects in shipped code labels Jun 3, 2021
@lindsaylevine
Copy link

@clareoneill hey claire! thanks for the detailed issue!! it seems like the only diff between the 5/26 successful build and 6/1 failed build is the netlify/build version, so i pinged some engineers internally. while we did only release 3.4.0 today, i can't rule out it being somewhat part of the issue. would it be possible to spin up a repo that reproduces the cannot find module error for us? that would be super helpful, though we do v much appreciate all the details already included!! 🙏

@lindsaylevine lindsaylevine added the status: needs reproduction this issue needs to provide a repo that reproduces the bug described label Jun 3, 2021
@clareoneill
Copy link
Author

Figured it out! NODE_ENV was set to production so the devDependencies weren't being installed during the build 🤦🏻 Thanks for pointing me in the right direction.

serhalp pushed a commit that referenced this issue Jun 13, 2024
* fix: separate response cache if debug logging header is used

* test: update 'new' assertions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: high status: needs reproduction this issue needs to provide a repo that reproduces the bug described type: bug code to address defects in shipped code
Projects
None yet
Development

No branches or pull requests

2 participants