通过node.js在mac上运行js时出错。如何修复?
我在文本编辑器中创建了一个.js文件,并尝试通过node js运行它:通过node.js在mac上运行js时出错。如何修复?,node.js,command-line-interface,Node.js,Command Line Interface,我在文本编辑器中创建了一个.js文件,并尝试通过node js运行它: var pizzaDoge = require('fs') pizzaDoge.writeFile("/index.html", "<h1>doge is fat</h1>", function(error) { if (error) { return console.log(error) } else { return console.log("you fed the dog
var pizzaDoge = require('fs')
pizzaDoge.writeFile("/index.html", "<h1>doge is fat</h1>", function(error) {
if (error) {
return console.log(error)
} else {
return console.log("you fed the doge!")
}
})
以防万一,错误号与我使用的是哪台计算机有关,我使用的是Mac。谢谢您的帮助。在Mac上,根文件夹(/
)需要根权限才能访问
请尝试使用/index.html
而不是/index.html
在当前文件夹下创建文件
{ Error: EACCES: permission denied, open '/index.html'
errno: -13,
code: 'EACCES',
syscall: 'open',
path: '/index.html' }