Open micmart opened 7 years ago
@micmart this one threw me for a while. For development, put your environment variables into .env
, and try adding
const env = require('dotenv').config()
to the top of index.js
, and adding "dotenv":"^4.0.0" to
package.json`
You probably won't want that in production though. Better to just export the environment variables directly there.
I have the same problem. RSA private key is in config.development.js but starting in development mode gives:
> node index.js
/home/jo/dev/staticman/node_modules/node-rsa/src/NodeRSA.js:178
throw Error("Empty key given");
^
Error: Empty key given
at NodeRSA.module.exports.NodeRSA.importKey (/home/jo/dev/staticman/node_modules/node-rsa/src/NodeRSA.js:178:19)
Found the problem. I had a JSON syntax error in the config.development.js. This got muffled away in a try {} catch (e) {}
I have the same problem. RSA private key is in config.development.js but starting in development mode gives:
> node index.js /home/jo/dev/staticman/node_modules/node-rsa/src/NodeRSA.js:178 throw Error("Empty key given"); ^ Error: Empty key given at NodeRSA.module.exports.NodeRSA.importKey (/home/jo/dev/staticman/node_modules/node-rsa/src/NodeRSA.js:178:19)
Wondering how you fixed? I get the same error and don't see an issue with the json syntax.
I'm unable to start staticman after following steps noted above. Here's my debug log.
0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'start' ]
2 info using npm@3.5.2
3 info using node@v8.10.0
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle staticman@2.0.0~prestart: staticman@2.0.0
6 verbose lifecycle staticman@2.0.0~prestart: unsafe-perm in lifecycle true
7 verbose lifecycle staticman@2.0.0~prestart: PATH: /usr/share/npm/bin/node-gyp-bin:/opt/staticman/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin
8 verbose lifecycle staticman@2.0.0~prestart: CWD: /opt/staticman
9 silly lifecycle staticman@2.0.0~prestart: Args: [ '-c', 'if [ ! -d node_modules ]; then npm install; fi' ]
10 silly lifecycle staticman@2.0.0~prestart: Returned: code: 0 signal: null
11 info lifecycle staticman@2.0.0~start: staticman@2.0.0
12 verbose lifecycle staticman@2.0.0~start: unsafe-perm in lifecycle true
13 verbose lifecycle staticman@2.0.0~start: PATH: /usr/share/npm/bin/node-gyp-bin:/opt/staticman/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin
14 verbose lifecycle staticman@2.0.0~start: CWD: /opt/staticman
15 silly lifecycle staticman@2.0.0~start: Args: [ '-c', 'node index.js' ]
16 silly lifecycle staticman@2.0.0~start: Returned: code: 1 signal: null
17 info lifecycle staticman@2.0.0~start: Failed to exec start script
18 verbose stack Error: staticman@2.0.0 start: node index.js
18 verbose stack Exit status 1
18 verbose stack at EventEmitter.node index.js
26 error Exit status 1
27 error Failed at the staticman@2.0.0 start script 'node index.js'.
27 error Make sure you have the latest version of node.js and npm installed.
27 error If you do, this is most likely a problem with the staticman package,
27 error not with npm itself.
27 error Tell the author that this fails on your system:
27 error node index.js
27 error You can get information on how to open an issue for this project with:
"npm-debug.log" 49L, 2967C 1,1 Top
@micmart this one threw me for a while. For development, put your environment variables into
.env
, and try addingconst env = require('dotenv').config()
to the top of
index.js
, and adding"dotenv":"^4.0.0" to
package.json`You probably won't want that in production though. Better to just export the environment variables directly there.
How did you push staticman to a dokku server? I'm getting the error "Empty key given" when I try to push using dokku. Any thoughts on what I need to do to fix? Thanks!
Is there any updates on this, I'm stuck at the same spot.
If recall right, its an issue with rsaPrivateKey in the config file. I used a command line tool to check my syntax.
On Mon, Feb 11, 2019, 1:52 PM Justin Rummel <notifications@github.com wrote:
Is there any updates on this, I'm stuck at the same spot.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/eduardoboucas/staticman/issues/128#issuecomment-462509302, or mute the thread https://github.com/notifications/unsubscribe-auth/AivBM-fQAFt7iodM3OH5YqK9T_CKhXUnks5vMeYEgaJpZM4Oj92g .
Thanks for the quick reply @shoreviewanalytics, however, it just leaves more questions. What was wrong w/ the config file? What command line tool did you use to check the syntax? I have something like the below (fake data):
{
"githubToken": "5091869e2c124aa7ad7a592bf8114a8b",
"rsaPriv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MxJe6a7
SMvGsJLwgrgvTFIPNXDHf6d/8Kpm7IiREdZ/i36RtXTuq6KJQeWmB6XZFYDD6MCTXy3QXh
dpDIIUuH/GkuHboZ4PTbw5XM1woY1nzdf9ljQtMtW6gBAAAAgFUBoX+vywpXVxCuni/9zS
hUXrejjxV+duYd1iQ96zm3nKdLv5WBL2JIsy9mkDd00c8Ab5C/Wuw7D60zDAQK/LoJLUJ2
A+luuuTGNU29vwNxLADzRvG5HoqrRvLh7NeOD3hjQH+/2YpD38EfiJzJ5V5ro3mqPcHd46
a6V9nWsIcZAAAAgQDU5VIjNAwD9pZE4CeN4tDRH5EE0/DNzPyivq5YMCw501Cr1BMK5lXe
GPVpdP37wYpVEsd08VQmiLge1maC8NkH7YKjZsVhiGwWaufylqfWpiNRf7crip6L+0wKqp
Ol8KzdtpQggEh59NdW5hoLyxvJJu2emuK1IdZN9aBtHtMsIwAAAIEAz5LoiTxnsJmNOxR4
boW9kvLSxvaeBc/r1jDXRY8fgR1KGvDrRp9v3HptcoLJwaZC6j1Ybbor39U/AyfFpk3vKS
VvyLpN8Hrh1vazp/+POfZXbhFfkdZABE1Cto+zC0GjVA/Od/daNRJnGIhoeoFrh3w0Tb6G
IOEJEr/8T6IgLwEAAAAJZGVsZXRlLW1lAQI=
-----END RSA PRIVATE KEY-----",
"port": 443
}
OK, couple of notes for future people. YES, the rsaPrivateKey is just one line (not over serval lines like you would expect). Also, for whatever reason I could not bind against port 443, but 8443 allowed me to start.
sadmin@staticman:~/staticman$ npm start
> staticman@2.0.0 prestart /home/sadmin/staticman
> if [ ! -d node_modules ]; then npm install; fi
> staticman@2.0.0 start /home/sadmin/staticman
> node index.js
Staticman API running on port 8443
Cool, I have a post on my blog on how to setup your own instance. Please have a look, leave a comment. It took me days to figure it out! 😁
https://shoreviewanalytics.github.io/Staticman-API-Dokku-Deployment/
On Tue, Feb 12, 2019, 12:01 PM Justin Rummel <notifications@github.com wrote:
OK, couple of notes for future people. YES, the rsaPrivateKey is just one line (not over serval lines like you would expect). Also, for whatever reason I could not bind against port 443, but 8443 allowed me to start.
sadmin@staticman:~/staticman$ npm start
staticman@2.0.0 prestart /home/sadmin/staticman if [ ! -d node_modules ]; then npm install; fi
staticman@2.0.0 start /home/sadmin/staticman node index.js
Staticman API running on port 8443
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/eduardoboucas/staticman/issues/128#issuecomment-462912288, or mute the thread https://github.com/notifications/unsubscribe-auth/AivBM7EZOohugHRiXG22q5M467rB5pbkks5vMx21gaJpZM4Oj92g .
Thanks @shoreviewanalytics ! I'll go through your documentation over the weekend
hello @shoreviewanalytics unfortunately still not getting anything to work. Used Digital Ocean and created my own Dokku on Ubuntu 18 LTD and I'm always getting stuck somewhere on /app/node_modules/node-rsa/src/NodeRSA.js
. I feel like your directions are more notes for yourself vs. directions, especially for someone who has ZERO experience with Dokku.
Hi Justin,
Unfortunately, I don't really remember more than the notes I took on how I did it. My explanation is far from a step by step, so I agree with you that it is really just my notes on the process. You can try the following for config.production.json. Please be sure that the .json is valid by using a validator and make sure that you don't wrap the rsaPrivatKey either. Where I say "insert public key here all on one line, no wrapping" is where you put your key.
{ "githubToken": "", "rsaPrivateKey": "-----BEGIN RSA PUBLIC KEY-----insert public key here all on one line, no wrapping==-----END RSA PUBLIC KEY-----", "port": 80 }
On Sat, Mar 2, 2019 at 12:53 PM Justin Rummel notifications@github.com wrote:
hello @shoreviewanalytics https://github.com/shoreviewanalytics unfortunately still not getting anything to work. Used Digital Ocean and created my own Dokku on Ubuntu 18 LTD and I'm always getting stuck somewhere on /app/node_modules/node-rsa/src/NodeRSA.js. I feel like your directions are more notes for yourself vs. directions, especially for someone who has ZERO experience with Dokku.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/eduardoboucas/staticman/issues/128#issuecomment-468943518, or mute the thread https://github.com/notifications/unsubscribe-auth/AivBMxLTA1sR54dy0VxUH9n69USOVIqqks5vSrqTgaJpZM4Oj92g .
Unfortunately, that does not fix the problem for me.
I followed your steps on https://github.com/eduardoboucas/staticman:
export NODE_ENV=development
When I start the server I get the following error:
Any hint how to resolve?
Node v8.2.1 MacOS Sierra v10.12.5