Skip to content
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

Netlify build failing if target in next.config.js changed to experimental-serverless-trace #3932

Closed
1 of 9 tasks
ani4aniket opened this issue Aug 29, 2021 · 3 comments
Closed
1 of 9 tasks
Labels
Package: nextjs Issues related to the Sentry Nextjs SDK Type: Bug

Comments

@ani4aniket
Copy link

Package + Version

  • @sentry/browser
  • @sentry/node
  • raven-js
  • raven-node (raven for node)
  • other:

Version:

"@sentry/nextjs": "^6.11.0"

Description

Describe your issue in detail, ideally, you have a reproducible demo that you can show.
When the target in next.config.js from serverless to experimental-serverless-trace, in the resolution of #3575, Netlify build is failing,
throws an error: Cannot find module '@prisma/client'

Netlify Logs:
https://pastebin.com/6bExettA

next.config.js

const { withSentryConfig } = require('@sentry/nextjs');
const moduleExports = {
  /* config options here */
  target: 'experimental-serverless-trace',
  env: {
    API_ENDPOINT: process.env.API_ENDPOINT,
  },
  webpack5: false,
  webpack(config, { isServer, dev: isDevelopmentMode }) {
    config.module.rules.push({
      test: /\.svg$/,
      issuer: {
        test: /\.(js|ts)x?$/,
      },
      use: [
        {
          loader: '@svgr/webpack',
          // https://react-svgr.com/docs/options/
        },
      ],
    });

    config.module.rules.push({
      test: /\.po$/,
      use: [
        {
          loader: 'ignore-loader',
        },
      ],
    });

    // Fixes npm packages that depend on `fs` module
    if (!isServer) {
      config.node = {
        fs: 'empty',
      };
    }

    // Attempt to ignore storybook files when doing a production build,
    // see also: https://github.com/vercel/next.js/issues/1914
    if (!isDevelopmentMode) {
      config.module.rules.push({
        test: /\.stories.(js|tsx?)/,
        loader: 'ignore-loader',
      });
    }
    return config;
  },
  poweredByHeader: false,
  images: {
    domains: ['unsplash.com'],
  },
};

const SentryWebpackPluginOptions = {
  silent: true,
};

module.exports = withSentryConfig(moduleExports, SentryWebpackPluginOptions);
@zgreen
Copy link

zgreen commented Sep 27, 2021

Seeing a similar error with this next.config.js (generated by the sentry wizard):

const { withSentryConfig } = require("@sentry/nextjs");

const SentryWebpackPluginOptions = {
  // Additional config options for the Sentry Webpack plugin. Keep in mind that
  // the following options are set automatically, and overriding them is not
  // recommended:
  //   release, url, org, project, authToken, configFile, stripPrefix,
  //   urlPrefix, include, ignore

  silent: true, // Suppresses all logs
  // For all available options, see:
  // https://github.com/getsentry/sentry-webpack-plugin#options.
};

const config = {
  reactStrictMode: true,
};
module.exports = withSentryConfig(config, SentryWebpackPluginOptions);

And the Netlify build error:

11:17:44 AM: ModuleNotFoundError: Module not found: Error: Can't resolve 'webpack' in '/opt/build/repo/node_modules/@next/react-refresh-utils'

Is it possible to just use @sentry/react for Netlify builds? Given that these are static builds anyway I'm not sure there's much/any value added by using the custom @sentry/next package.

Thanks!

@github-actions
Copy link
Contributor

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you label it Status: Backlog or Status: In Progress, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

@albin-woto
Copy link

albin-woto commented Nov 9, 2021

I have the same issue Cannot find module 'webpack' with this next.config.js on Netlify, even if a don't set a target the same error occurs. I didn't had this issue before setting sentry on the project.


const moduleExports = { target: 'experimental-serverless-trace' }

const sentryWebpackPluginOptions = {
  silent: true,
}

module.exports = withSentryConfig(moduleExports, sentryWebpackPluginOptions)

Currently using "@sentry/nextjs": "^6.14.1"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: nextjs Issues related to the Sentry Nextjs SDK Type: Bug
Projects
None yet
Development

No branches or pull requests

4 participants