node里https模块出现

fs.js:427

  return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);

                 ^

Error: ENOENT, no such file or directory 'ssh_key.pem'

    at Object.fs.openSync (fs.js:427:18)

    at Object.fs.readFileSync (fs.js:284:15)

    at Object.<anonymous> (/Users/lichao/Desktop/nodeStudy/https.js:5:9)

    at Module._compile (module.js:456:26)

    at Object.Module._extensions..js (module.js:474:10)

    at Module.load (module.js:356:32)

    at Function.Module._load (module.js:312:12)

    at Function.Module.runMain (module.js:497:10)

    at startup (node.js:119:16)

    at node.js:902:3


源码为:

var https=require('https');

var fs=require('fs');


var options={

key:fs.readFileSync('ssh_key.pem'),

cert:fs.readFileSync('ssh_cert.pem')

}


https

.createServer(options,function(req,res){

res.writeHead(200);

res.end('Hello zhdail')

}).listen('8080')


代小代
浏览 2175回答 3
3回答

_潇潇暮雨

文件路径有问题吧,当前目录是./
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Node.js