staticman: Error thrown from NodeRSA.js:178 "Empty key given" when attempting to start the server

I followed your steps on https://github.com/eduardoboucas/staticman:

  1. Clone the repository and install the dependencies via npm
  2. Create a development config file from the sample file.
  3. Edit the newly-created config file with your GitHub access token, SSH private key and the port to run the server.
  4. I additionally run export NODE_ENV=development
  5. Start the server.

When I start the server I get the following error:

martm106-3AH03Y:staticman martm106$ npm start

> staticman@2.0.0 prestart /Users/martm106/Dev/staticman
> if [ ! -d node_modules ]; then npm install; fi


> staticman@2.0.0 start /Users/martm106/Dev/staticman
> node index.js

/Users/martm106/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 (/Users/martm106/Dev/staticman/node_modules/node-rsa/src/NodeRSA.js:178:19)
    at Object.<anonymous> (/Users/martm106/Dev/staticman/controllers/encrypt.js:8:5)
    at Module._compile (module.js:569:30)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
    at Module.require (module.js:513:17)
    at require (internal/module.js:11:18)
    at new StaticmanAPI (/Users/martm106/Dev/staticman/server.js:13:14)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! staticman@2.0.0 start: `node index.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the staticman@2.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/martm106/.npm/_logs/2017-07-26T13_49_18_210Z-debug.log

Any hint how to resolve?

Node v8.2.1 MacOS Sierra v10.12.5

About this issue

  • Original URL
  • State: open
  • Created 7 years ago
  • Reactions: 1
  • Comments: 15

Commits related to this issue

Most upvoted comments

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 .

@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.