title: Dockerizing gRPC Server (Node) Issue: [Error: Failed to load gRPC binary module because it was not installed for the current system]
body: <p><strong>Whenever I run my docker image, I keep getting an error in terms of incompatibility between systems/architecture for node...</strong></p>
  <p><strong>I tried this command:</strong></p>
  <pre><code>npm rebuild --target=8.1.0 --target_platform=linux --target_arch=x64 --target_libc=glibc --update-binary
  </code></pre>
  <p><strong>But the problem still persists...</strong></p>
  <p><strong>Here are my files for more context:</strong></p>
  <p><strong>Full error After I try to run my docker image</strong></p>
  <pre><code>Error: Failed to load gRPC binary module because it was not installed for the current system
  Expected directory: node-v83-linux-x64-glibc
  Found: [node-v72-darwin-x64-unknown]
  This problem can often be fixed by running &quot;npm rebuild&quot; on the current system
  Original error: Cannot find module '/usr/src/app/node_modules/grpc/src/node/extension_binary/node-v83-linux-x64-glibc/grpc_node.node'
  
  Require stack:
  - /usr/src/app/node_modules/grpc/src/grpc_extension.js
  - /usr/src/app/node_modules/grpc/src/client_interceptors.js
  - /usr/src/app/node_modules/grpc/src/client.js
  - /usr/src/app/node_modules/grpc/index.js
  - /usr/src/app/booksServer.js
      at Object.&lt;anonymous&gt; (/usr/src/app/node_modules/grpc/src/grpc_extension.js:53:17)
      at Module._compile (internal/modules/cjs/loader.js:1236:30)
      at Object.Module._extensions..js (internal/modules/cjs/loader.js:1257:10)
      at Module.load (internal/modules/cjs/loader.js:1085:32)
      at Function.Module._load (internal/modules/cjs/loader.js:950:14)
      at Module.require (internal/modules/cjs/loader.js:1125:19)
      at require (internal/modules/cjs/helpers.js:75:18)
      at Object.&lt;anonymous&gt; (/usr/src/app/node_modules/grpc/src/client_interceptors.js:144:12)
      at Module._compile (internal/modules/cjs/loader.js:1236:30)
      at Object.Module._extensions..js (internal/modules/cjs/loader.js:1257:10) {
    code: 'MODULE_NOT_FOUND'
  </code></pre>
  <p><strong>Dockerfile (running my gRPC node server)</strong></p>
  <pre><code>FROM node:latest
  WORKDIR /usr/src/app
  COPY package*.json ./
  COPY . /usr/src/app
  RUN npm install
  EXPOSE 30043
  CMD [&quot;node&quot;, &quot;booksServer.js&quot;]
  
  </code></pre>
  <p><strong>Booksserver.js</strong> <strong>(GRPC Server)</strong></p>
  <pre><code>// const PROTO_PATH = &quot;../protos/books.proto&quot;;
  const path = require('path');
  const PROTO_PATH = path.join(__dirname, '../protos/books.proto');
  const grpc = require(&quot;grpc&quot;);
  const protoLoader = require(&quot;@grpc/proto-loader&quot;);
  const express = require(&quot;express&quot;);
  const controller = require(&quot;./booksController.js&quot;);
  const app = express();
  app.use(express.json());
  
  const packageDefinition = protoLoader.loadSync(PROTO_PATH, {
    keepCase: true,
    longs: String,
    enums: String,
    arrays: true,
  });
  
  const booksProto = grpc.loadPackageDefinition(packageDefinition);
  
  const { v4: uuidv4 } = require(&quot;uuid&quot;);
  
  const server = new grpc.Server();
  
  server.addService(booksProto.BooksService.service, {
    CreateBook: (call, callback) =&gt; {
      console.log(&quot;call to CreateBook&quot;);
  
      //sample will take the call information from the client(stub)
      const book = {
        title: call.request.title,
        author: call.request.author,
        numberOfPages: call.request.numberOfPages,
        publisher: call.request.publisher,
        id: call.request.id,
      };
  
      controller.createBook(book);
  
      let meta = new grpc.Metadata();
      meta.add(&quot;response&quot;, &quot;none&quot;);
      call.sendMetadata(meta);
  
      callback(
        null,
        //bookmodel.create
        {
          title: `completed for: ${call.request.title}`,
          author: `completed for: ${call.request.author}`,
          numberOfPages: `completed for: ${call.request.numberOfPages}`,
          publisher: `completed for: ${call.request.publisher}`,
          id: `completed for: ${call.request.id}`,
        }
      );
    },
    GetBooks: (call, callback) =&gt; {
      console.log(&quot;call to GetBooks&quot;);
      // read from database
      let meta = new grpc.Metadata();
      meta.add('response', 'none');
      call.sendMetadata(meta);
  
      controller.getBooks(callback);
    },
    GetBookByID: (call, callback) =&gt; {
      console.log(&quot;call to GetBookByID&quot;);
      
      let sampleID = {id: 100};
  
      let meta = new grpc.Metadata();
      meta.add('response', 'none');
      call.sendMetadata(meta);
  
      controller.getBookByID(sampleID, callback);
    },
    DeleteBook: (call, callback) =&gt; {
      //sample will take the call information from the client(stub)
      const bookID = {
        id: call.request.id,
      };
  
      //this actually sends data to booksController.
      controller.deleteBook(bookID);
  
      let meta = new grpc.Metadata();
      meta.add('response', 'none');
      call.sendMetadata(meta);
  
      // delete from database
      callback(null, { message: &quot;DELETED&quot; });
    },
  });
  
  server.bind(&quot;127.0.0.1:30043&quot;, grpc.ServerCredentials.createInsecure());
  console.log(&quot;booksServer.js running at http://127.0.0.1:30043&quot;);
  
  console.log(&quot;call from books server&quot;);
  
  server.start();
  
  </code></pre>