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

App crashing after updating to Next 12 and deploying on Vercel #30400

Closed
hoodwink73 opened this issue Oct 27, 2021 · 3 comments
Closed

App crashing after updating to Next 12 and deploying on Vercel #30400

hoodwink73 opened this issue Oct 27, 2021 · 3 comments
Labels
bug Issue was opened via the bug report template.

Comments

@hoodwink73
Copy link

What version of Next.js are you using?

12.0.0

What version of Node.js are you using?

14.15.4

What browser are you using?

chrome

What operating system are you using?

macOS

How are you deploying your application?

Vercel

Describe the Bug

The app runs normally with Next 11.1.0
But after updating to Next 12, it runs fine on local, even deploys successfully, but the app is crashing when visited

The error logs on Vercel shows this

[GET] /
08:29:41:23
2021-10-27T02:59:43.514Z	d7ab2a6b-1181-4326-8a48-2039f292a92b	ERROR	Error: Cannot find module '/var/task/node_modules/next/dist/server/next.js'. Please verify that the package.json has a valid "main" entry
    at tryPackage (internal/modules/cjs/loader.js:320:19)
    at Function.Module._findPath (internal/modules/cjs/loader.js:533:18)
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:875:27)
    at Function.Module._load (internal/modules/cjs/loader.js:745:27)
    at Module.require (internal/modules/cjs/loader.js:961:19)
    at require (internal/modules/cjs/helpers.js:92:18)
    at Object.<anonymous> (/var/task/node_modules/@sentry/nextjs/dist/utils/instrumentServer.js:7:14)
    at Module._compile (internal/modules/cjs/loader.js:1072:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
    at Module.load (internal/modules/cjs/loader.js:937:32) {
  code: 'MODULE_NOT_FOUND',
  path: '/var/task/node_modules/next/package.json',
  requestPath: 'next'
}
2021-10-27T02:59:43.515Z	d7ab2a6b-1181-4326-8a48-2039f292a92b	ERROR	Error: Cannot find module '/var/task/node_modules/next/dist/server/next.js'. Please verify that the package.json has a valid "main" entry
    at tryPackage (internal/modules/cjs/loader.js:320:19)
    at Function.Module._findPath (internal/modules/cjs/loader.js:533:18)
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:875:27)
    at Function.Module._load (internal/modules/cjs/loader.js:745:27)
    at Module.require (internal/modules/cjs/loader.js:961:19)
    at require (internal/modules/cjs/helpers.js:92:18)
    at Object.<anonymous> (/var/task/node_modules/@sentry/nextjs/dist/utils/instrumentServer.js:7:14)
    at Module._compile (internal/modules/cjs/loader.js:1072:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
    at Module.load (internal/modules/cjs/loader.js:937:32) {
  code: 'MODULE_NOT_FOUND',
  path: '/var/task/node_modules/next/package.json',
  requestPath: 'next',
  page: '/'
}
RequestId: d7ab2a6b-1181-4326-8a48-2039f292a92b Error: Runtime exited with error: exit status 1
Runtime.ExitError

This is my next.config.js

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

const {
  NODE_ENV,
  SENTRY_AUTH_TOKEN,
  VERCEL_GITHUB_COMMIT_SHA,
  NEXT_PUBLIC_SENTRY_PROJECT
} = process.env;

const SENTRY_ORG = "...";
const SENTRY_PROJECT = NEXT_PUBLIC_SENTRY_PROJECT ||  `...`;

const moduleExports = {
  productionBrowserSourceMaps: false,
  async headers() {
    return [
      {
        // matching all API routes
        source: "/api/:path*",
        headers: [
          {
            key: "Access-Control-Allow-Headers",
            value: "sentry-trace"
          }
        ]
      }
    ];
  },
  eslint: {
    // Warning: Dangerously allow production builds to successfully complete even if
    // your project has ESLint errors.
    ignoreDuringBuilds: true
  }
};

const SentryWebpackPluginOptions = {
  authToken: SENTRY_AUTH_TOKEN,
  ignore: ["node_modules"],
  include: ".next",
  release: VERCEL_GITHUB_COMMIT_SHA,
  org: SENTRY_ORG,
  project: SENTRY_PROJECT,
  silent: NODE_ENV === "production" ? false : true
};

module.exports = withSentryConfig(moduleExports, SentryWebpackPluginOptions);

Expected Behavior

The app should run normally as it does with Next 11.1.0

To Reproduce

This is a private repo. And I haven't been able to reduce it to minimum code to reproduce this issue.
But downgrading from Next 12 to Next 11.1.0 makes it runs fine

@hoodwink73 hoodwink73 added the bug Issue was opened via the bug report template. label Oct 27, 2021
@ijjk
Copy link
Member

ijjk commented Oct 27, 2021

Closing as a duplicate of #30349

@ijjk ijjk closed this as completed Oct 27, 2021
@hoodwink73
Copy link
Author

Oh well, will try without Sentry.

Hopefully, the issue gets resolved on the sentry repo.

@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template.
Projects
None yet
Development

No branches or pull requests

3 participants