Closed ai-leonid closed 1 year ago
This module support CJS
user. It will never add "type": "module"
inside package.json
.
@leonid-ilin I have revisit the problem. Can you check if version 3.0.1
resolve the problem?
@climba03003 Hello, now we can import fastify-formidable but not use it:
file:///workspace/node_modules/fastify-formidable/lib/mjs/index.js:2
import { IncomingForm } from 'formidable';
^^^^^^^^^^^^
SyntaxError: Named export 'IncomingForm' not found. The requested module 'formidable' 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 'formidable';
const { IncomingForm } = pkg;
at ModuleJob._instantiate (node:internal/modules/esm/module_job:123:21)
at async ModuleJob.run (node:internal/modules/esm/module_job:189:5)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:526:24)
at async loadESM (node:internal/process/esm_loader:91:5)
at async handleMainPromise (node:internal/modules/run_main:65:12)
It works if we import formidable like this.
import pkg from 'formidable';
const { IncomingForm } = pkg;
Thank you for this package and your work!
@N1kl8s Can you check if version 3.0.2
fix your issue?
@climba03003 Thank you very much! Now it works just fine.
Hello! After importing this plugin into
index.mjs
file in my fastify project with esm modules, I've get this error:I think you could try, to add
"type": "module",
intopackage.json
file