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

Module not found: Can't resolve 'console' #24966

Closed
saltz opened this issue May 10, 2021 · 3 comments
Closed

Module not found: Can't resolve 'console' #24966

saltz opened this issue May 10, 2021 · 3 comments
Labels
examples Issue/PR related to examples good first issue Easy to fix issues, good for newcomers

Comments

@saltz
Copy link

saltz commented May 10, 2021

What example does this report relate to?

with-sentry

What version of Next.js are you using?

10.2.0

What version of Node.js are you using?

16.1.0

What browser are you using?

Firefox

What operating system are you using?

Windows

How are you deploying your application?

next start

Describe the Bug

When resolving a nextjs page the error is thrown in the server side console.

error - ./node_modules/@sentry/node/esm/integrations/console.js:19:0
Module not found: Can't resolve 'console'

I switched from the old with-sentry example to the new one which uses the early adaptors version of @sentry/nextjs.
A similar error could occur in the previous example, but it was resolved by specifying the alias in the next.config.js file.

if (!isServer) {
    config.resolve.alias['@sentry/node'] = '@sentry/browser'
}

I also tried using both cross-env and esm which are mentioned as a potential solution in previous versions of the with-sentry example. "cross-env NODE_OPTIONS=\"-r esm\" next This unfortunately produces the same result.

Expected Behavior

The page gets compiled successfully and returned by the server to the browser.

To Reproduce

clone the with-sentry example app.

@saltz saltz added bug Issue was opened via the bug report template. examples Issue/PR related to examples labels May 10, 2021
@timneutkens timneutkens added good first issue Easy to fix issues, good for newcomers and removed bug Issue was opened via the bug report template. labels May 11, 2021
@JonasBa
Copy link

JonasBa commented May 12, 2021

Same issue here, I removed the old sentry/browser and sentry/node to replace it with the new sentry/nextjs plugin.

My next config is just

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

const nextConfig = {
  future: {
    webpack5: true
  }
}

module.exports = withSentryConfig(nextConfig)

@saltz
Copy link
Author

saltz commented May 14, 2021

I ended up resolving the issue by the suggestion mentioned in this thread/ issue.

In short check and rename all imports of sentry to the new correct import: import * as Sentry from "@sentry/nextjs";

@saltz saltz closed this as completed May 14, 2021
@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 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
examples Issue/PR related to examples good first issue Easy to fix issues, good for newcomers
Projects
None yet
Development

No branches or pull requests

4 participants