Why I got TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received null
See original GitHub issueSupport plan
- which support plan is this issue covered by? (e.g. Community, Sponsor, or Enterprise):Community
- is this issue currently blocking your project? (yes/no):yes
- is this issue affecting a production system? (yes/no):yes
Context
- node version:15
- module (formidable) version:2.0.0 canary
- environment (e.g. node, browser, native, OS):Version 87.0.4280.88 (Official Build) (64-bit), Debian 10 x64
- used with (i.e. popular names of modules):
- any other relevant information:
What are you trying to achieve or the steps to reproduce?
When I try to upload my files to the server I get this error. My code on localhost works without problem, but when I run the code on the server I get this error. I want my files after upload to be on my favorite path on the server.
spawn("sudo", ["mkdir", `${tempTrim}`])
spawn("sudo", ["chown", "-R", "sigma:sigma", `${tempTrim}`])
var form = formidable({ multiples: true, maxFileSize: 700 * 1024 * 1024, keepExtensions: true});
form.on('progress', function (bytesReceived, bytesExpected) {
console.log('PROGRESS');
console.log(bytesReceived);
console.log(bytesExpected);
});
form.once('error', console.error)
form.on('fileBegin', function(name, file) {
file.path = `${tempTrim}/${file.name}`
})
form.on('file', (filename, file) => {
form.emit('data', { name: 'file', key: filename, value: file });
});
form.on('field', (fieldName, fieldValue) => {
form.emit('data', { name: 'field', key: fieldName, value: fieldValue });
});
form.once('end', async() => {
console.log('Done!');
await zipShapeFiles()
});
form.parse(req, (err, fields, files) => {
if (err) {
console.error('Error', err)
next(err)
return
}
What was the result you got?
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received null
at new NodeError (node:internal/errors:278:15)
at validateString (node:internal/validators:123:11)
at Object.extname (node:path:1273:5)
at IncomingForm._uploadPath (/home/sigma/sigmamap/node_modules/formidable/src/Formidable.js:440:22)
at IncomingForm._handlePart (/home/sigma/sigmamap/node_modules/formidable/src/Formidable.js:288:18)
at IncomingForm.onPart (/home/sigma/sigmamap/node_modules/formidable/src/Formidable.js:241:10)
at MultipartParser.<anonymous> (/home/sigma/sigmamap/node_modules/formidable/src/plugins/multipart.js:147:14)
at MultipartParser.emit (node:events:376:20)
at MultipartParser.EventEmitter.emit (node:domain:470:12)
at addChunk (node:internal/streams/readable:305:12)
at readableAddChunk (node:internal/streams/readable:280:9)
at MultipartParser.Readable.push (node:internal/streams/readable:219:10)
at MultipartParser._handleCallback (/home/sigma/sigmamap/node_modules/formidable/src/parsers/Multipart.js:95:10)
at MultipartParser._transform (/home/sigma/sigmamap/node_modules/formidable/src/parsers/Multipart.js:228:16)
at MultipartParser.Transform._write (node:internal/streams/transform:184:23)
at writeOrBuffer (node:internal/streams/writable:388:12) {
code: 'ERR_INVALID_ARG_TYPE'
}
Error TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received null
at new NodeError (node:internal/errors:278:15)
at validateString (node:internal/validators:123:11)
at Object.extname (node:path:1273:5)
at IncomingForm._uploadPath (/home/sigma/sigmamap/node_modules/formidable/src/Formidable.js:440:22)
at IncomingForm._handlePart (/home/sigma/sigmamap/node_modules/formidable/src/Formidable.js:288:18)
at IncomingForm.onPart (/home/sigma/sigmamap/node_modules/formidable/src/Formidable.js:241:10)
at MultipartParser.<anonymous> (/home/sigma/sigmamap/node_modules/formidable/src/plugins/multipart.js:147:14)
at MultipartParser.emit (node:events:376:20)
at MultipartParser.EventEmitter.emit (node:domain:470:12)
at addChunk (node:internal/streams/readable:305:12)
at readableAddChunk (node:internal/streams/readable:280:9)
at MultipartParser.Readable.push (node:internal/streams/readable:219:10)
at MultipartParser._handleCallback (/home/sigma/sigmamap/node_modules/formidable/src/parsers/Multipart.js:95:10)
at MultipartParser._transform (/home/sigma/sigmamap/node_modules/formidable/src/parsers/Multipart.js:228:16)
at MultipartParser.Transform._write (node:internal/streams/transform:184:23)
at writeOrBuffer (node:internal/streams/writable:388:12) {
code: 'ERR_INVALID_ARG_TYPE'
}
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received null
at new NodeError (node:internal/errors:278:15)
at validateString (node:internal/validators:123:11)
at Object.extname (node:path:1273:5)
at IncomingForm._uploadPath (/home/sigma/sigmamap/node_modules/formidable/src/Formidable.js:440:22)
at IncomingForm._handlePart (/home/sigma/sigmamap/node_modules/formidable/src/Formidable.js:288:18)
at IncomingForm.onPart (/home/sigma/sigmamap/node_modules/formidable/src/Formidable.js:241:10)
at MultipartParser.<anonymous> (/home/sigma/sigmamap/node_modules/formidable/src/plugins/multipart.js:147:14)
at MultipartParser.emit (node:events:376:20)
at MultipartParser.EventEmitter.emit (node:domain:470:12)
at addChunk (node:internal/streams/readable:305:12)
at readableAddChunk (node:internal/streams/readable:280:9)
at MultipartParser.Readable.push (node:internal/streams/readable:219:10)
at MultipartParser._handleCallback (/home/sigma/sigmamap/node_modules/formidable/src/parsers/Multipart.js:95:10)
at MultipartParser._transform (/home/sigma/sigmamap/node_modules/formidable/src/parsers/Multipart.js:228:16)
at MultipartParser.Transform._write (node:internal/streams/transform:184:23)
at writeOrBuffer (node:internal/streams/writable:388:12)
What result did you expect ?
I’d expect my files to transfer to my favorite path on my server and the upload process to complete without any empty file or incomplete file.
Issue Analytics
- State:
- Created 3 years ago
- Comments:11 (5 by maintainers)
Top Results From Across the Web
The "path" argument must be of type string ... - Stack Overflow
I'm working on a project in React and ran into a problem that has me stumped. Whenever I run yarn start I get...
Read more >[Fix] TypeError [ERR_INVALID_ARG_TYPE]: The “path ...
Have you run into the error “TypeError [ERR_INVALID_ARG_TYPE]: The “path” argument must be of type string. Received undefined”? In this story I'll go...
Read more >The "path" argument must be of type string. Received - YouTube
JavaScript : TypeError [ERR_INVALID_ARG_TYPE]: The " path " argument must be of type string. Received type undefined raised when starting ...
Read more >The path argument must be of type string - Reactgo
In this tutorial, we are going to learn about how to fix the TypeError [ERR_INVALID_ARG_TYPE]: The “path” argument must be of type string....
Read more >npm err! code err_invalid_arg_type npm err! the path ...
yml Press Ctrl-C to stop this script TypeError [ERRINVALIDARG_TYPE]: The "path" argument must be of type string or an instance of Buffer or...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Bunch of thanks🙏, my problem solved, I’m using html tag
<form action="" method="post" enctype=enctype='multipart/form-data'>
instead of fetch API and know I can upload without any error, at least not yet 😉, If I encounter dilemma again such as Abort… Or path error I’ll write here. However It seems I can launch my project the day after tomorrow without any stress and problemYou’re now getting
Request aborted
error. Hm.Try using
formidable-serverless
, it will be integrated in v2 soon with #594