usage demo comes error: "TypeError: dest.on is not a function"
See original GitHub issueI run the usage demo:
const yauzl = require("yauzl");
yauzl.open("./OMStarPS_npi.capacity_11.5.0.zip", {lazyEntries: true}, function(err, zipfile) {
if (err) throw err;
zipfile.readEntry();
zipfile.on("entry", function(entry) {
if (/\/$/.test(entry.fileName)) {
// Directory file names end with '/'.
// Note that entires for directories themselves are optional.
// An entry's fileName implicitly requires its parent directories to exist.
zipfile.readEntry();
} else {
// file entry
zipfile.openReadStream(entry, function(err, readStream) {
if (err) throw err;
readStream.on("end", function() {
zipfile.readEntry();
});
readStream.pipe('./');
});
}
});
});
comes error:
_stream_readable.js:501
dest.on('unpipe', onunpipe);
^
TypeError: dest.on is not a function
at AssertByteCountStream.Readable.pipe (_stream_readable.js:501:8)
at D:\node\www\test\test-unzip\yauzl.js:19:20
at D:\node\www\test\test-unzip\node_modules\yauzl\index.js:575:7
at D:\node\www\test\test-unzip\node_modules\yauzl\index.js:631:5
at D:\node\www\test\test-unzip\node_modules\fd-slicer\index.js:32:7
at FSReqWrap.wrapper [as oncomplete] (fs.js:682:17)
I just wanna unzip a zip file.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:12 (5 by maintainers)
Top Results From Across the Web
What does this mean: TypeError: dest.on is not a function
The error is happening in the pipe() method in readable-stream. dest is the name of the first argument to pipe() ; the fact...
Read more >[Solved]-TypeError: dest.on is not a function-node.js
You want fs.createWriteStream(). fs.openSync() just returns a file descriptor. So it would be: k.stderr.pipe(fs.createWriteStream('/dev/ ...
Read more >Getting Started with Gulp.js - Semaphore Tutorial
Learn how to set up and use Gulp.js, a task runner for Node.js based on ... To copy files, we only need to...
Read more >Express multer middleware
Usage. Multer adds a body object and a file or files object to the request object. The body object contains the values of...
Read more >Minifying Javascript Files Error dest.on is not a function
'use strict'; var gulp = require('gulp'), concat = require('gulp-concat'), uglify = require('gulp-uglify'), //I know the teacher has ...
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 FreeTop 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
Top GitHub Comments
Ah, yeah. Sorry. That require call is confusing. I’ve updated it with a comment explaining how to translate that to be useful outside of yauzl’s source code directory structure.
I took another look at your code from the OP, and I don’t know why I didn’t see this before, but the problem is here:
You have to
pipe()
into a stream, not a file path. In my example I linked above I make a file write stream here: https://github.com/thejoshwolfe/yauzl/blob/51010ce4e8c7e6345efe195e1b4150518f37b393/examples/unzip.js#L193 https://github.com/thejoshwolfe/yauzl/blob/51010ce4e8c7e6345efe195e1b4150518f37b393/examples/unzip.js#L196There are lots of other kinds of streams you can pipe the file contents into.
what is the easiest way to unzip a zip file?