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!

2 Answers 2


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

It seems like the issue is that the 'ethereumjs-testrpc' package is not installed in your Express app container. You can try adding it to your package.json dependencies and then running npm install again in your Dockerfile, like so:

Install app dependencies

COPY package.json /usr/src/app/ RUN npm install ethereumjs-testrpc RUN npm install

Also, you can try adding the ethereumjs-testrpc package globally in your Dockerfile, like so:

RUN npm install -g ethereumjs-testrpc

Additionally, if you're still having issues, you can check that the package is properly installed in your container by running the following command in your container:

npm list -g ethereumjs-testrpc

It should show the package and its version number

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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