Comments (12)
Using the following command to import can solve the problem, and I don't know why
const {formidable} = require("formidable");
from formidable.
Unbelievable
from formidable.
https://npmfs.com/package/formidable/3.5.1/dist/index.cjs#L1682
the exported default is a function
from formidable.
And yet when I revert to V2 it works and simply upgrade to V3 again it fails with same error which makes no sense I agree but its happening
const formidable = require("formidable");
app.post("/upload", (req, res, next) => {
const form = formidable({ multiples: true, uploadDir: `${__dirname}/upload` });
form.parse(req, (err, fields, files) => {
if (err) {
next(err);
return;
}
var file = files.file.filepath;
var mimetype = files.file.mimetype;
if (mimetype === "image/png" || mimetype === "image/jpeg") {
Jimp.read(file)
.then(async (logo) => {
await logo.resize(48, 48).quality(100).writeAsync(`${__dirname}/output/icon.png`);
var getNewFile = fs.readFileSync(`${__dirname}/output/icon.png`, "base64");
fs.unlinkSync(file);
fs.unlinkSync(`${__dirname}/output/icon.png`);
res.end(getNewFile);
})
.catch((err) => {
errorHandler("Error : Jimp : " + err);
});
} else {
fs.unlinkSync(file);
res.end("WRONG MIMETYPE");
}
});
});
It fails at line
const form = formidable({ multiples: true, uploadDir: `${__dirname}/upload` });
from formidable.
Have the same problem.
const {formidable} = require("formidable");
helped me too, i think it mey be problem with @types/formidable
from formidable.
Same problem here
from formidable.
That solved it for me thanks everyone!
from formidable.
Is everyone having this issue using Typescript ?
from formidable.
Is everyone having this issue using Typescript ?
No I am not
This works though:
Have the same problem.
const {formidable} = require("formidable");
helped me too, i think it mey be problem with @types/formidable
from formidable.
Im not using Typescript and have that issue but solved from the suggestion above
from formidable.
That's normal. It's a SemVer Major release, and it's documented. We tried to have backwards compat but yeah.
We have exports.default
, but i think we should also have module.exports
for all that to work "properly".. in general, i think we can safely drop CJS for v4.
from formidable.
Using the following command to import can solve the problem, and I don't know why
const {formidable} = require("formidable");
I meet the same problem, does it affect any subsequent code?
from formidable.
Related Issues (20)
- TS Options Type Definition missing createDirsFromUploads HOT 1
- Attach fields to req.body and files to req.files like multer HOT 1
- [deps] Check for breaking changes in Dependabot PRs HOT 1
- @cunha-ambisis you should create a new form on each request (inside app.use) HOT 1
- Make multipart parser less dependent on NodeJS HOT 2
- Regression in Formidable v3, which can crash a server HOT 7
- form.parse's Promise never resolves in tests HOT 8
- Hexoid Error (?)
- Buffer usage HOT 2
- Files parsed by `IncomingForm().parse` are not automatically cleaned up or deleted. HOT 6
- firstValues export in index HOT 4
- Build giving the error in `cloudflare-pages` preset HOT 2
- maxFileSize not working as it should HOT 1
- TypeScript - Unable to access FormidableError on formidable.errors HOT 9
- Convert 'firstValues' helper into an option for Formidable constructor. HOT 2
- Support the contentType of multipart field. HOT 2
- VERSION_NOTES.md is misleading
- Engines missing in `package.json` and wrong version of Node.js supported listed in README
- How to wait for the result of writeHandler in a formidable file upload request? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from formidable.