FileySync does not find files which are in a child folder (I also tried the same folder) of other modules which are found.
console.log __dirname
https = require('https')
fs = require('fs')
sslOptions = {
key: fs.readFileSync('./config/ssl/server.key'),
cert: fs.readFileSync('./config/ssl/server.crt'),
ca: fs.readFileSync('./config/ssl/ca.crt'),
requestCert: true,
rejectUnauthorized: false
}
secureServer = https.createServer(sslOptions,app).listen('3030', () ->
console.log("Secure Express server listening on port 3030")
)
configDB = require('./config/database.js')(environment)
The database.js is found, the ssl files are not. The logged dirname:
---my project folder--/.tmp/serve
File Permissions:
config
-rw-r--r-- 1 MasterG staff 93 14 Apr 14:06 config.js
-rw-r--r-- 1 MasterG staff 526 14 Apr 14:06 database.js
drwxr-xr-x 6 MasterG staff 204 14 Apr 13:51 ssl
ssl
-rw-r--r-- 1 MasterG staff 912 14 Apr 14:06 ca.crt
-rw-r--r-- 1 MasterG staff 963 14 Apr 14:06 ca.key
-rw-r--r-- 1 MasterG staff 924 14 Apr 14:06 server.crt
-rw-r--r-- 1 MasterG staff 887 14 Apr 14:06 server.key
Error: unction strWrapper(err, written) { ^ Error:
ENOENT, no such file or directory './config/server.key'
at Error (native)
at Object.fs.openSync (fs.js:502:18)
at Object.fs.readFileSync (fs.js:354:15)
at Object.<anonymous> (/Users/MasterG/Desktop/PROJEKTE/gideon/.tmp/serve/server.js:25:13)
at Object.<anonymous> (/Users/MasterG/Desktop/PROJEKTE/gideon/.tmp/serve/server.js:76:4)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
sslOptions = {
key: fs.readFileSync(__dirname + '/config/ssl/server.key'),
cert: fs.readFileSync(__dirname + '/config/ssl/server.crt'),
ca: fs.readFileSync(__dirname + '/config/ssl/ca.crt'),
requestCert: true,
rejectUnauthorized: false
}
To include __dirname did the trick, strange because in that tutorial it seemed to work without: http://greengeckodesign.com/blog/2013/06/15/creating-an-ssl-certificate-for-node-dot-js/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With