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

Can't Use exceptionless/react on Next.js project #103

Closed
polluterofminds opened this issue Sep 1, 2021 · 4 comments
Closed

Can't Use exceptionless/react on Next.js project #103

polluterofminds opened this issue Sep 1, 2021 · 4 comments
Assignees
Labels

Comments

@polluterofminds
Copy link
Contributor

When trying to import the @exceptionless/react package in Next.js, the following error occurs:

SyntaxError: Named export 'fromError' not found. The requested module 'stacktrace-js' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from 'stacktrace-js';
const { fromError } = pkg;

Steps to reproduce:

  1. npx create-next-app app-name
  2. npm i @exceptionless/react
  3. in pages/index.js add the import line at the top: import { Exceptionless } from "@exceptionless/react";
@niemyjski
Copy link
Member

@polluterofminds Did you enable esm support as described here: https://nextjs.org/blog/next-11-1#es-modules-support

@polluterofminds
Copy link
Contributor Author

polluterofminds commented Sep 3, 2021

Just tested this, and I get the same error. Looks like this is a known Next.js issue: vercel/next.js#25454

@niemyjski
Copy link
Member

Did their fix solve this? I think we need to bring in stacktrace.js and convert it to be 100% esm

@niemyjski
Copy link
Member

I just confirmed this is still broken in 2.0.1 but is fixed in main! I tested it by running npm install --save ../Exceptionless.JavaScript/packages/react

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants