question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:1
  • Comments:15

github_iconTop GitHub Comments

2reactions
shoreviewanalyticscommented, Mar 4, 2019

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 .

1reaction
flyinggrizzlycommented, Dec 18, 2017

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

node-rsa errors when trying to decrypt message with private key
When I start the node script I do the following for the encryption... var NodeRSA = require('node-rsa'); var myDecrypter = new ...
Read more >
node-rsa - npm
Start using node-rsa in your project by running `npm i node-rsa`. ... const encrypted = key.encrypt(text, 'base64');.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found