SyntaxError: Named export 'trough' not found.
kulsumansari opened this issue · 2 comments
Initial checklist
- I read the support docs
- I read the contributing guide
- I agree to follow the code of conduct
- I searched issues and couldn’t find anything (or linked relevant results below)
Affected packages and versions
react-markdown@8.0.3
Link to runnable example
react-markdown version 8.0.3
Steps to reproduce
I am using react-markdown version 8.0.3 on next.js 12 application .
on creating build on server I am getting following error :
file:///codebuild/output/src375/src/s3/00/node_modules/react-markdown/node_modules/unified/lib/index.js:25
import {trough} from 'trough'
^^^^^^
SyntaxError: Named export 'trough' not found. The requested module 'trough' 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 'trough';
const {trough} = pkg;
at ModuleJob._instantiate (node:internal/modules/esm/module_job:124:21)
at async ModuleJob.run (node:internal/modules/esm/module_job:181:5)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:281:24)
at async importModuleDynamicallyWrapper (node:internal/vm/module:437:15)
> Build error occurred
Error: Failed to collect page data for /blog
at /codebuild/output/src375/src/s3/00/node_modules/next/dist/build/utils.js:916:15 {
type: 'Error'
}
I fixed this temporarily bt degrading react-markdown version to 7.1.2 the error seems to resolve.
Expected behavior
Build should be created successfully.
Actual behavior
Build should be created successfully.
Runtime
Node v16
Package manager
npm 8
OS
Linux
Build and bundle tools
Webpack, Next.js
If through
is a CommonJS module, it seems you are using an old version.
The version of unified
in react-markdown
is 10+: https://github.com/remarkjs/react-markdown/blob/main/package.json#L94.
The first version of unified in the 10+ line includes through
2+: https://github.com/unifiedjs/unified/blame/3d504623341ccd9cea19bc2a14c0cf2b28254088/package.json#L54.
The first version of through in the 2+ line is ESM-only: https://github.com/wooorm/trough/blame/6db47a437b4cf73ba75a8214766e1bff49eb951d/package.json#L21.
Updating your dependencies, throwing away package locks and node_modules
, should do the trick.
Hi! This was closed. Team: If this was fixed, please add phase/solved
. Otherwise, please add one of the no/*
labels.