Nodejs fs write file error,anyone can help?
发布于 9 年前 作者 xiebaochun 4483 次浏览 最后一次编辑是 8 年前 来自 问答

when in use bellow code to write a json file to local system, encounter bellow error,as some wrong about the permmision.

var myData = { name: ‘test’, version: ‘1.0’ }

var outputFilename = “C:\Program Files (x86)\Skype\Phone\share.json”

fs.writeFile(outputFilename, JSON.stringify(myData, null, 4), function(err) { if (err) { console.log(err); } else { console.log("JSON saved to " + outputFilename); } });

error shotscreen: QQ图片20150206114920.png

Anyone can help?thanks in advance!

7 回复

You don’t have permission to access that file. Learn what UAC is here http://en.wikipedia.org/wiki/User_Account_Control Or alternatively please run your node process under administrator account: http://www.7tutorials.com/how-run-programs-administrator-windows-7

when in use bellow code to write a json file to local system, encounter bellow error,as some wrong about the permmision.

When I use the code below to write a json file in the local file system, there is an error which shows something wrong with the file permissions.

Anyone can help?thanks in advance!

Can anyone help please? Thanks in advance!

稍微更正下?请精通英语的大神指正

说中文好不

run cmd as administrator then invoke you script

一堆拼写错误就不要来扮外籍人士了。

看到这篇,我特意注册了一个账号来笑一下

回到顶部