Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm install grpc failed

Tags:

node.js

npm

grpc

enviroment: node version v8.9.3 npm >5.x

start install grpc by npm, I got some errors
npm install -g grpc

the errors:

gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit 
(/Users/yuham/.nvm/versions/node/v8.9.3/lib/node_modules/node-
gyp/lib/build.js:258:23)
gyp ERR! stack     at emitTwo (events.js:126:13)
gyp ERR! stack     at ChildProcess.emit (events.js:214:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit 
(internal/child_process.js:198:12)
gyp ERR! System Darwin 17.2.0
...
gyp ERR! cwd /Users/yuham/.nvm/versions/node/v8.9.3/lib/node_modules/grpc
gyp ERR! node -v v8.9.3
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute 
...
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> 
(/Users/yuham/.nvm/versions/node/v8.9.3/lib/node_modules/
grpc/node_modules/node-
pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at emitTwo (events.js:126:13)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:214:7)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:925:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit 
(internal/child_process.js:209:5)
node-pre-gyp ERR! System Darwin 17.2.0
node-pre-gyp ERR! command "/Users/yuham/.nvm/versions/node/v8.9.3/bin/node" 
"/Users/yuham/.nvm/versions/node/v8.9.3/lib/node_modules/
grpc/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build" "--
library=static_library"
node-pre-gyp ERR! cwd 
/Users/yuham/.nvm/versions/node/v8.9.3/lib/node_modules/grpc
node-pre-gyp ERR! node -v v8.9.3
node-pre-gyp ERR! node-pre-gyp -v v0.6.38
node-pre-gyp ERR! not ok
Failed to execute '/Users/yuham/.nvm/versions/node/v8.9.3/bin/node 
/Users/yuham/.nvm/versions/node/v8.9.3/lib/node_modules/node-gyp/bin/node-
gyp.js build --fallback-to-build --library=static_library --
module=/Users/yuham/.nvm/versions/node/v8.9.3/lib/node_modules/
grpc/src/node/extension_binary/node-v57-darwin-x64/grpc_node.node --
module_name=grpc_node --
module_path=/Users/yuham/.nvm/versions/node/v8.9.3/lib/node_modules/
grpc/src/node/extension_binary/node-v57-darwin-x64' (1)

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-pre-gyp install --fallback-to-build --
library=static_library`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional 
logging output above.

npm ERR! A complete log of this run can be found in:

I tried to install different version of grpc, but got the same result while this error caused by node-pre-gyp or node-gyp? My computer system is osx --lts. I can't find any good idea or solution. How to fix it?

like image 798
Ham Yu Avatar asked Dec 25 '17 07:12

Ham Yu


2 Answers

Run this command, it will work

npm install -g xxx --unsafe-perm

But I don't understand what '--unsafe-perm' means?

like image 161
Ham Yu Avatar answered Sep 23 '22 16:09

Ham Yu


I found that the problem was that the package request was missing. Installing it before installing grpc fixed my issues. If you have a package depending on grpc, install request first.

yarn add request

yarn add grpc

A colleague mentioned something about the company proxy. Dunno if that's actually the problem, but adding request did fix the issue.

like image 34
Emanuel Lindström Avatar answered Sep 22 '22 16:09

Emanuel Lindström