3

I was doing a proof of concept on gRPC using node.js

Here is my package.json

{
  "name": "grpc-node-demo",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "dependencies": {
    "@grpc/proto-loader": "^0.1.0",
    "grpc": "^1.11.0",
    "lodash": "^4.6.1"
  }
}

After writing in proto file, client and server files. When I run the command node server.js I got the following error

PS C:\Learnings\node\grpc-nodejs-demo> node server.js
C:\Learnings\node\grpc-nodejs-demo\node_modules\grpc\src\grpc_extension.js:58
    throw e;
    ^

Error: Failed to load C:\Learnings\node\grpc-nodejs-demo\node_modules\grpc\src\node\extension_binary\node-v83-win32-x64-unknown\grpc_node.node. \\?\C:\Learnings\node\grpc-nodejs-demo\node_modules\grpc\src\node\extension_binary\node-v83-win32-x64-unknown\grpc_node.node is not a valid Win32 application.
\\?\C:\Learnings\node\grpc-nodejs-demo\node_modules\grpc\src\node\extension_binary\node-v83-win32-x64-unknown\grpc_node.node
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:1122:18)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (C:\Learnings\node\grpc-nodejs-demo\node_modules\grpc\src\grpc_extension.js:32:13)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
PS C:\Learnings\node\grpc-nodejs-demo>

Any thoughts??

1 Answer 1

2

After some research, I did the following steps to resolve the issue

  • I was missing node-gyp - which is Node.js native addon build tool. It can be installed by

    npm install -g node-gyp

  • Install Python

  • Install Visual C++ Build Environment

  • Clean up node-modules

  • Then do in the folder npm install

The following link talks the above steps in detail: https://github.com/nodejs/node-gyp#on-windows

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.