admin管理员组文章数量:1418050
I am trying to copy one folder to another using node.js here is folder path:-
D:\node\files\11\j1_1\j1_2\j1_3
I want to copy folder j1_3 to path
D:\node\files\11\j1_1\
here is my code:-
var source = fs.createReadStream(old);
var dest = fs.createWriteStream(newp);
source.pipe(dest);
source.on('end', function () { /* copied */ });
source.on('error', function (err) {
console.log("hi");
/* error */
});
but I am getting this error:-
events.js:72
throw er; // Unhandled 'error' event
^
Error: EISDIR, open 'D:\node\files\11\j1_1'
I have also try fs.rename function but getting same error.
I am trying to copy one folder to another using node.js here is folder path:-
D:\node\files\11\j1_1\j1_2\j1_3
I want to copy folder j1_3 to path
D:\node\files\11\j1_1\
here is my code:-
var source = fs.createReadStream(old);
var dest = fs.createWriteStream(newp);
source.pipe(dest);
source.on('end', function () { /* copied */ });
source.on('error', function (err) {
console.log("hi");
/* error */
});
but I am getting this error:-
events.js:72
throw er; // Unhandled 'error' event
^
Error: EISDIR, open 'D:\node\files\11\j1_1'
I have also try fs.rename function but getting same error.
Share Improve this question edited Sep 3, 2015 at 15:37 Qix - MONICA WAS MISTREATED 15.2k17 gold badges92 silver badges156 bronze badges asked Jul 25, 2014 at 8:26 Umesh SehtaUmesh Sehta 10.7k5 gold badges42 silver badges68 bronze badges 2- one additional clarification. The error you are getting at the writestream is because fs does not automatically append the new filename to the dest. Which cp and ncp do, so to fix the issue you could have also added the new filename to the dest instead of using ncp / cp. Resulting in: newp + path.basename(old); – Bram Commented Jan 13, 2016 at 21:45
- @Bram thanks for information :) – Umesh Sehta Commented Jan 14, 2016 at 4:50
1 Answer
Reset to default 4First: EISDIR means "error! target is a dir"(i guess), about the error
Second: ncp is what you need i guess
本文标签: javascriptnodejs Error EISDIRopen ErrorStack Overflow
版权声明:本文标题:javascript - Node.js Error: EISDIR, open Error - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745250831a2649812.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论