admin管理员组文章数量:1201801
Ok first off... I'm new to Node.js. I'm trying to convert a word document to HTML then scrapping it to obtain the content. Then pump it into an existing engine.
With that being said, everything was running fairly smoothly until today. I just got the fs.writeFile working last night and stepped away from it. This morning without touching it and trying to run it I receive this:
here's the block where the error is being called.
//COPY TEMPLATE AND PASTE
fs.readFile("./Templates/TextBasedEvent.xml", function (err, data){
if (err) {
throw err;
}
var contentHolder = data.toString(),
contentHolder = contentHolder.replace(/%EVENTNUMBER%/gi, id),
contentHolder = contentHolder.replace(/%CONTENT%/gi, contents);
fs.writeFile("./bin/xml/" + id + ".xml", contentHolder, function (err){
if (err) {
throw err;
}
});
});
Does it have something to do with how the variable is placed in the file path? also the throw err for it just seems weird that it soft returned in between where the variable is.
Thanks!
Edit: The issue was with newline being pulled in, with the variable.
Ok first off... I'm new to Node.js. I'm trying to convert a word document to HTML then scrapping it to obtain the content. Then pump it into an existing engine.
With that being said, everything was running fairly smoothly until today. I just got the fs.writeFile working last night and stepped away from it. This morning without touching it and trying to run it I receive this:
here's the block where the error is being called.
//COPY TEMPLATE AND PASTE
fs.readFile("./Templates/TextBasedEvent.xml", function (err, data){
if (err) {
throw err;
}
var contentHolder = data.toString(),
contentHolder = contentHolder.replace(/%EVENTNUMBER%/gi, id),
contentHolder = contentHolder.replace(/%CONTENT%/gi, contents);
fs.writeFile("./bin/xml/" + id + ".xml", contentHolder, function (err){
if (err) {
throw err;
}
});
});
Does it have something to do with how the variable is placed in the file path? also the throw err for it just seems weird that it soft returned in between where the variable is.
Thanks!
Edit: The issue was with newline being pulled in, with the variable.
Share Improve this question edited Feb 1, 2014 at 23:53 Dirly asked Feb 1, 2014 at 23:14 DirlyDirly 2451 gold badge4 silver badges11 bronze badges 2- 3 From the log it seems that the id contains a newline. – Kurt Pattyn Commented Feb 1, 2014 at 23:19
- yup that makes sense. I just tried something different with the way the word file was exported to html. Seems I just forgot that step! – Dirly Commented Feb 1, 2014 at 23:52
1 Answer
Reset to default 22There are a few things that might cause ENOENT
when writing a file.
- The destination directory (in this case,
E:\Desktop\SniffIt\bin\xml
) does not exist. - A newline (CR and/or LF) in the filename.
You should be using a proper XML parser to read your input file. This would probably help you avoid the spurious newlines you're getting.
本文标签:
版权声明:本文标题:javascript - Node.js Error ENOENT, open "filepath" when nothing has been changed - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738639352a2104221.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论