`node-pre-gyp install --fallback-to-build` failed during MeanJS installation on OSX

node.jsMacosNpmMeanjs

node.js Problem Overview


I just bought myself a mac book after using Windows for a long time.

I was trying to work on a MeanJS project that I had been working on. Doing npm install on the project throws error

Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/Users/Aayush/Work/lishn/repo/lishn-alpha/node_modules/grunt-node-inspector/node_modules/node-inspector/node_modules/v8-debug/build/debug/v0.4.6/node-v46-darwin-x64/debug.node --module_name=debug --module_path=/Users/Aayush/Work/lishn/repo/lishn-alpha/node_modules/grunt-node-inspector/node_modules/node-inspector/node_modules/v8-debug/build/debug/v0.4.6/node-v46-darwin-x64' (1)
npm ERR! Darwin 15.0.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
npm ERR! node v4.1.1
npm ERR! npm  v2.14.4
npm ERR! code ELIFECYCLE
> 
> npm ERR! v8-debug@0.4.6 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the v8-debug@0.4.6 install script 'node-pre-gyp install --fallback-to-build'.
npm ERR! This is most likely a problem with the v8-debug package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-pre-gyp install --fallback-to-build
npm ERR! You can get their info via:
npm ERR!     npm owner ls v8-debug
npm ERR! There is likely additional logging output above.

I tried clearing cache.

I tried installing node-pre-gyp with sudo and --unsafe-perm

I also tried to fresh install a MEAN project, with the same error.

I can't seem to find what the problem is here.

Node Version - 5.0.0

NPM Version - 3.3.10

node.js Solutions


Solution 1 - node.js

i have tried upgrading node-gyp:

sudo npm install -g node-gyp

It worked for me.

I find the solution here, I hope it can help.

Solution 2 - node.js

russfrisch commented 4 days ago: > > I was experiencing this same issue. Changing in the version for > grunt-node-inspector to prepend a ">=" instead of a "~" got this to > work for me.

Link to github page where I found this solution.

Link to my post on StackoverFlow

Solution 3 - node.js

I was gone through same problem solved after lot efforts. It is because of npm version is not compatible with gprc version. So we need to update the npm.

npm update
npm install 

Solution 4 - node.js

This might not work for everyone, but I updated node and it fixed the issue for me when none of the above did

Solution 5 - node.js

This seems issue with my node upgrade. How ever I solved it with the following approach.

First uninstall the cli, clear cashe, and reinstall with these commands

npm uninstall -g @angular/cli
npm cache clean
npm install -g @angular/cli

Then install node-pre-gyp

npm install -g node-pre-gyp

Restart your terminal and see if the issue is resolved.

Solution 6 - node.js

Just use this command and it will handle this error npm install --unsafe-perm --allow-root

Solution 7 - node.js

I also face the same problem. I found a solution for that.

bcrypt required C++, python, and node-pre-gyp.

sudo apt-get install g++
sudo apt-get install -y build-essential python
npm install node-pre-gyp

for more details check: Installation-Instructions

Solution 8 - node.js

Alright so after some debugging the following dependencies are using an older version of touch:

./node_modules/bower/node_modules/decompress-zip/package.json:    "touch": "0.0.3"
./node_modules/bower/node_modules/lockfile/package.json:    "touch": "0"
./node_modules/gulp-nodemon/node_modules/nodemon/package.json:    "touch": "1.0.0",
./node_modules/gulp-nodemon/node_modules/touch/package.json:    "touch": "./bin/touch.js"
./node_modules/nodemon/package.json:    "touch": "~0.0.3",

With that I was able to get meanJS working with node 5.

Here is the history on the commands I ran:

git clone https://github.com/meanjs/mean.git
cd mean
nvm install 5
nvm use 5
npm install
which node-gyp
npm install -g node-pre-gyp
sudo xcodebuild -license
npm install

Had some issues and then:

I added the following line:

#!/usr/bin/env node

To the top of the file ./mean/node_modules/.bin/touch

And then:

npm install

And of course maybe throw in a sudo rm -rf ./node_modules && npm cache clean before retrying.

Solution 9 - node.js

As @ocean800 stated I updated node. The below solution is for Ubuntu 16.04 that worked for me, but something similar on OSX may fix this issue.

On Ubuntu 16.04, what worked for me was upgrading node

https://stackoverflow.com/questions/41195952/updating-nodejs-on-ubuntu-16-04#41196107

I am replicating solution from the above link below

To update, you can install n

sudo npm install -g n

Then just :

sudo n latest

or a specific version

sudo n 8.9.0

Then try and install

sudo npm install <package>

Solution 10 - node.js

Hope my scenario can help someone else. I had the same problem with the package bcrypt. First, I have tried with npm i -g node-gyp as suggested by Anne but the problem persisted. Then I read again the error message to have a better understanding of the problem and discovered that the script fails to build the package from scratch - since a precompiled version doesn't exist. In particular, it can't find the g++ command so I solved installing the build-essential package with sudo apt install build-essential -y.

Solution 11 - node.js

Following command work for me:

sudo npm i -g node-pre-gyp

Solution 12 - node.js

I was solved this problem too: Just reinstall node to LTS version by nvm:

nvm install --lts

nvm use --lts

Then rm -rf node_modules And npm i

Solution 13 - node.js

I recently had this error on a fresh OSX install of Node using homebrew. Brew installed the latest at the time 13.8.0.

I downgraded the last "stable" release of node.

sudo npm install -g n  ## Installs Node Version Switcher
sudo n stable          ## To switch to latest stable version

Then the rest of my npm installs finished and passed the dreaded gprc errors!

Solution 14 - node.js

are you running the example from the node_modules folder?

They are not supposed to be ran from there.

Create the following file on your project instead:

post-data.js

var Curl = require( 'node-libcurl' ).Curl,
   querystring = require( 'querystring' );

var curl = new Curl(),
  url  = 'http://posttestserver.com/post.php',
data = { //Data to send, inputName : value
    'input-arr[0]' : 'input-arr-val0',
    'input-arr[1]' : 'input-arr-val1',
    'input-arr[2]' : 'input-arr-val2',
    'input-name' : 'input-val'
};

//You need to build the query string, 
// node has this helper function, but it's limited for real use cases (no support for 
array values for example)
data = querystring.stringify( data );

 curl.setOpt( Curl.option.URL, url );
 curl.setOpt( Curl.option.POSTFIELDS, data );
 curl.setOpt( Curl.option.HTTPHEADER, ['User-Agent: node-libcurl/1.0'] );
 curl.setOpt( Curl.option.VERBOSE, true );

 console.log( querystring.stringify( data ) );

 curl.perform();

 curl.on( 'end', function( statusCode, body ) {

console.log( body );

this.close();
});

curl.on( 'error', curl.close.bind( curl ) );

Run with node post-data.js

ref:https://github.com/JCMais/node-libcurl/issues/98

Solution 15 - node.js

Happened to me on node 13.7.0 and npm 6.13.6 (macOS Mojave).

I had the following as part of my errors:

found X vulnerabilities (Y moderate, Z high)
  run `npm audit fix` to fix them, or `npm audit` for details

And running the following fixed the problem:

  1. $ npm audit fix

  2. $ npm install

Solution 16 - node.js

Try toreinstall XCode’s command-line tools with xcode-istall

That's worked for me.

Solution 17 - node.js

> npm ERR! [email protected] install: node-pre-gyp install --fallback-to-build

The above error was fixed by installing bcrypt using the following command:

npm --build-from-source install bcrypt@3.0.6

Solution 18 - node.js

After uninstalling node-gyp, try installing again.

sudo npm uninstall -g node-gyp
sudo npm install -g node-gyp

Solution 19 - node.js

I tried all the other suggested solutions and none of them worked. I solved the issue by removing all spaces and "&" characters from the name of all root folders.

Solution 20 - node.js

try these

sudo chown -R $(whoami) ~/.npm

sudo chown -R $(whoami) /usr/local/lib

sudo chown -R $(whoami) /usr/local/bin

Then try your command again without sudo. e.g.

npm install -g npm@latest

Check this global installs sudo fail on mac for more details

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionaayush shresthaView Question on Stackoverflow
Solution 1 - node.jsAnneView Answer on Stackoverflow
Solution 2 - node.jsManyQuestionsView Answer on Stackoverflow
Solution 3 - node.jsVishal ChavanView Answer on Stackoverflow
Solution 4 - node.jsocean800View Answer on Stackoverflow
Solution 5 - node.jsTadele AyelegnView Answer on Stackoverflow
Solution 6 - node.jsRaph JacksunView Answer on Stackoverflow
Solution 7 - node.jsRana JahidView Answer on Stackoverflow
Solution 8 - node.jsjmunschView Answer on Stackoverflow
Solution 9 - node.jsenthusiasticgeekView Answer on Stackoverflow
Solution 10 - node.jsJacopoView Answer on Stackoverflow
Solution 11 - node.jswizzfizz94View Answer on Stackoverflow
Solution 12 - node.jsvad nevodView Answer on Stackoverflow
Solution 13 - node.jsmbsparkView Answer on Stackoverflow
Solution 14 - node.jsShantanu KhondView Answer on Stackoverflow
Solution 15 - node.jsDut A.View Answer on Stackoverflow
Solution 16 - node.jsLucas BrogniView Answer on Stackoverflow
Solution 17 - node.jsVictor TeppaView Answer on Stackoverflow
Solution 18 - node.jskamalesh biswasView Answer on Stackoverflow
Solution 19 - node.jsKhaled BaghdadiView Answer on Stackoverflow
Solution 20 - node.jsRuth AgbasimaloView Answer on Stackoverflow