Postinstall fails with SyntaxError: Named export 'copy' not found.
markbrocato opened this issue · 2 comments
markbrocato commented
Please check all that apply
- visual bug
- functional bug
- able to consistently reproduce
Expected Behavior
"postinstall": "react-flagpack" succeeds
Current Behavior
When running the postinstall task (react-flagpack), I get this error:
> console-monorepo@0.0.0 postinstall
> react-flagpack
file:///Users/mark/Code/console-ui/node_modules/react-flagpack/cli/flagpack.js:3
import { copy } from 'fs-extra'
^^^^
SyntaxError: Named export 'copy' not found. The requested module 'fs-extra' 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 'fs-extra';
const { copy } = pkg;
at ModuleJob._instantiate (node:internal/modules/esm/module_job:134:21)
at async ModuleJob.run (node:internal/modules/esm/module_job:217:5)
at async ModuleLoader.import (node:internal/modules/esm/loader:316:24)
at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:123:5)
Node.js v20.15.0
npm error code 1
npm error path /Users/mark/Code/console-ui
npm error command failed
npm error command sh -c react-flagpack
Steps to Reproduce
- add "postinstall": "react-flagpack" to package.json scripts
- add "react-flagpack": "^2.0.4" to package.json dependencies
- run npm i
Your Environment
- Mac OS
- Node 20
- npm 10.7.0
- turbo monorepo
zoeyfrisart commented
Hi there,
Apologies it appears I've forgotten to add fs-extra as a dependency.
I'll release a new version that resolves this sometime next week.
In the meantime you can work around this by installing the dependency into your project manually using npm i fs-extra
zoeyfrisart commented
@markbrocato Just pushed a new version that should resolve this issue! Let me know if you're still facing issues