Can't Use exceptionless/react on Next.js project
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:
- npx create-next-app app-name
- npm i @exceptionless/react
- in
pages/index.jsadd the import line at the top:import { Exceptionless } from "@exceptionless/react";
@polluterofminds Did you enable esm support as described here: https://nextjs.org/blog/next-11-1#es-modules-support
Just tested this, and I get the same error. Looks like this is a known Next.js issue: https://github.com/vercel/next.js/issues/25454
Did their fix solve this? I think we need to bring in stacktrace.js and convert it to be 100% esm
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