Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Node 10 - `node-gyp rebuild` error during npm install

I've recently upgraded to Node 10 and when I run npm install I get the following error:

make: *** [Release/obj.target/memwatch/src/init.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack     at ChildProcess.emit (events.js:182:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:240:12)
gyp ERR! System Darwin 18.2.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/david/Documents/gitlab/project/node_modules/memwatch-next
gyp ERR! node -v v10.15.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-gyp rebuild`
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.

Working on 'macOS Mojave', I worked on the same project with Node10 without any issues. Please advise what can be causing the error?

like image 259
David Faizulaev Avatar asked Jan 17 '19 13:01

David Faizulaev


People also ask

How do I get rid of gyp error?

Please uninstall node. js and use the Node v14. x. It will solve it automatically.

What is node-gyp in NPM?

node-gyp is a cross-platform command-line tool written in Node. js for compiling native addon modules for Node. js. It contains a vendored copy of the gyp-next project that was previously used by the Chromium team, extended to support the development of Node.

Is Python required for node-gyp?

node-gyp dependencies js should cover it for you. However, if you are an add-on developer, you probably need to install node-gyp globally. To use node-gyp, first, we'll need to install a Python runtime, the make utility, and a C or C++ compiler.


2 Answers

Use NVM for managing node. It is really helpful. I had the same error but solved it by using the latest Node LTS version. That can be done with NVM easily by a single command.

nvm install --lts
like image 158
Mugilan E.S. Avatar answered Sep 18 '22 09:09

Mugilan E.S.


Resolved the issue by updating npm to latest version & running npm rebuild.

like image 40
David Faizulaev Avatar answered Sep 21 '22 09:09

David Faizulaev