Node.js writeFileSync无法正确写入文件

问题描述 投票:0回答:1

我们在Web应用程序中使用Node.js写入文件时遇到问题。使用IISNode安装Node.js。

[开发服务器上的一切工作正常,但是相同的代码在生产服务器(Windows 7,IIS7,Windows Server 2008 R2 Standard,Service Pack 1)上却出现问题。基本上,单击按钮时,节点将创建多个HTML文件,并将内容写入其中。问题在于内容未写入所有创建的文件。将创建所有文件,但某些文件将保留为空白,不包含任何内容。

这里是用于创建和写入文件的代码摘录:

const $ = cheerio.load(cssData + videoHtml + pageData.content);
let indexFile = fs.openSync(file, 'w+')
fs.writeFileSync(indexFile, $.html(), { encoding: 'utf8' })
fs.closeSync(indexFile)
javascript node.js iis-7 windows-server-2008-r2
1个回答
0
投票
    const $ = cheerio.load(cssData + videoHtml + pageData.content); 
 fs.writeFileSync(file, $.html(), { encoding: 'utf8' , mode : 0755})
 fs.closeSync(indexFile)

尝试在选项中添加模式

© www.soinside.com 2019 - 2024. All rights reserved.