在node-webkit和Node.js中运行相同的代码
var fs = require('fs')
// var fs = process.mainModule.exports.fs // node-webkit
fs.readFile('/xxxx/xx','utf-8', function (e) {
console.log(e)
})
在 Node.js 中,errno 是 34
{ [Error: ENOENT, open '/xxxxx/xx'] errno: 34, code: 'ENOENT', path: '/xxxxx/xx' }
在node-webkit中,它是-2
{"errno":-2,"code":"ENOENT","path":"/xxxx/xx"}
为什么错误号不同?
有没有像this one这样的node-webkit errno 备忘单对于 Node.js?
最佳答案
我遇到了同样的错误,这是由于使用相对路径造成的。尝试直接从 xx 读取,而不是从/xxxx/xx
希望能解决
关于node.js - 为什么node-webkit中的errno与Node.js不同?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23158277/