I'm taking a stab at creating a set-up where I have a Docker container from which I run ethereumjs/testrpc (an Ethereum testing environment) and another Docker container running an Express app. I then wanted to be able to connect the two and, let's say, show account balances in my Express app.

My Dockerfile is

FROM node:boron

# Create app directory
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

# Install app dependencies
COPY package.json /usr/src/app/
RUN npm install
# RUN npm install -g ethereumjs-testrpc --> tested adding this line
# did not work either

# Bundle app source
COPY . /usr/src/app


CMD [ "npm", "start" ]

and docker-compose looks as follows

version: "2.0"
    build: .
      - .:/usr/src/app
      - "3000:3000"
      - mongo
    image: mongo
      - "27017:27017"
    image: ethereumjs/testrpc:latest

The error output I get looks like

web_1       | module.js:471
web_1       |     throw err;
web_1       |     ^
web_1       | 
web_1       | Error: Cannot find module 'ethereumjs-testrpc'
web_1       |     at Function.Module._resolveFilename (module.js:469:15)
web_1       |     at Function.Module._load (module.js:417:25)
web_1       |     at Module.require (module.js:497:17)
web_1       |     at require (internal/module.js:20:19)
web_1       |     at Object.<anonymous> (/usr/src/app/app.js:7:15)
web_1       |     at Module._compile (module.js:570:32)
web_1       |     at Object.Module._extensions..js (module.js:579:10)
web_1       |     at Module.load (module.js:487:32)
web_1       |     at tryModuleLoad (module.js:446:12)
web_1       |     at Function.Module._load (module.js:438:3)

Lastly, the beginning of my app.js is

var express = require('express');
var path = require('path');
var favicon = require('serve-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var TestRPC = require("ethereumjs-testrpc"); // these two lines are throwing
web3.setProvider(TestRPC.provider()); // the errors

I'm not understanding how to fix this and have tried different things, none of which seem to work. Any pointers in the right direction would be much appreciated!


Do you have ethereumjs-testrpc in the dependencies section of your package.json? e.g:

"dependencies": {
  "ethereumjs-testrpc": "^4.0.1"

If not, it could lead to the error you are getting.

Running npm install ethereumjs-testrpc --save will automatically add this to your package.json. Note, this is a one time command and doesn't need to be part of the Dockerfile. It just updates your package.json using the current latest version.

Also, if you removed the -g from

# RUN npm install -g ethereumjs-testrpc --> tested adding this line

... that would probably also work - but having it in your package.json removes the need to do this because it will get installed in the command on the previous line:

RUN npm install

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.