I am trying to build a docker image using open zepplin libraries. It works until it has to import the zepellin library, for which it can't seem to find.

Here is what my docker image looks like :

FROM node:10-alpine

WORKDIR /usr/src/app


COPY cdp-contracts/ ./rpc
COPY cdp-platform/  ./backend

RUN rm -rf backend/node_modules
RUN rm -rf rpc/node_modules

RUN apk add --no-cache --virtual .gyp \
    autoconf \
    automake \
    g++ \
    libpng-dev \
    libtool \
    make \
    nasm \
    python \
    git \
  && npm i -g wait-on concurrently truffle npm@latest \
  && concurrently 'cd rpc;  npm init -y ; npm install --save-exact openzeppelin-solidity; npm init -y ; npm i npm@latest -g ' 'cd backend; npm i npm@latest -g ; npm rebuild bcrypt --build-from-source' \
  && apk del .gyp

WORKDIR /usr/src/app/rpc

RUN truffle compile --all

WORKDIR /usr/src/app/backend

RUN mkdir -p build/
RUN ln -sf ../../rpc/build/contracts build/contracts

WORKDIR /usr/src/app/backend


CMD [ "npm", "run", "middleware" ]

Here is the import line from my contract :

import "../node_modules/openzeppelin-solidity/contracts/token/ERC20/ERC20.sol";

Note: From the documentation:

After that, you'll get all the library's contracts in the node_modules/openzeppelin-solidity/contracts folder. Because Truffle and other Ethereum development toolkits understand node_modules, you can use the contracts in the library like so

import 'openzeppelin-solidity/contracts/ownership/Ownable.sol';

contract MyContract is Ownable {

Reference: https://openzeppelin.org/api/docs/get-started.html

When I try to reference the node module, or call it import it as above, I keep running into this error:

Error: Could not find /usr/src/app/rpc/node_modules/openzeppelin-solidity/contracts/token/ERC20/ERC20.sol from any sources; imported from /usr/src/app/rpc/contracts/CarbonToken.sol at /usr/local/lib/node_modules/truffle/build/webpack:/packages/truffle-resolver/index.js:76:1

I will appreciate any guidance on this

1 Answer 1


I had a packagelock.json file there messing it up. Once I took it out it worked like a treat

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.