76

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
Alex
  • 8,461
  • 6
  • 37
  • 49
aayush shrestha
  • 1,858
  • 2
  • 17
  • 33
  • I have found some threads suggesting to downgrade node and npm. I haven't verified if that works yet. I would want to solve this without having to downgrade. – aayush shrestha Nov 01 '15 at 15:39
  • I would suggest at least downgrading to `4.2.x` since it is the latest long term release, which was only released a few weeks ago. If it works there, then try using `5.x` to see what breaks, there's a chance that the npm modules haven't been updated to handle `5.x` yet since its only been a couple days? Or at the very least save yourself some trouble by not using sudo with npm or node, and consider using `nvm`. – jmunsch Nov 01 '15 at 15:54
  • What happens when node-pre-gyp tries to build? (its the text above the npm errors) . Also the node version that you are using to build with is 4.1.1 `npm ERR! node v4.1.1` – jmunsch Nov 01 '15 at 16:34

21 Answers21

58

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.

MonoThreaded
  • 11,429
  • 12
  • 71
  • 102
Anne
  • 672
  • 5
  • 6
9

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

Community
  • 1
  • 1
ManyQuestions
  • 1,069
  • 1
  • 16
  • 34
7

This seems issue with my node upgrade. However, 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.

Tadele Ayelegn
  • 4,126
  • 1
  • 35
  • 30
7

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 
geisterfurz007
  • 5,292
  • 5
  • 33
  • 54
Vishal Chavan
  • 334
  • 3
  • 3
5

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

ocean800
  • 3,489
  • 13
  • 41
  • 73
3

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

kgangadhar
  • 4,886
  • 5
  • 36
  • 54
Rana Jahid
  • 31
  • 3
3

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

2

I have the same error and I could resolve it in this way

I needed the canvas package -> https://www.npmjs.com/package/canvas

In my case I used MacOS, so I installed the dependencies:

$ brew install pkg-config cairo pango libpng jpeg giflib librsvg pixman

And this is all!

1

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.

jmunsch
  • 22,771
  • 11
  • 93
  • 114
  • I tried installing the old version of node-pre-gyp : `npm install node-pre-gyp@v0.7.x`. It worked for me. I don't know why the new version didn't work. – Lakshmi Swetha G Feb 13 '17 at 08:24
1

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

updating nodejs on ubuntu 16.04

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>
enthusiasticgeek
  • 2,640
  • 46
  • 53
  • 1
    Prefixing with `sudo` is generally a bad advise, you should not need it: https://stackoverflow.com/questions/25290986/how-to-fix-eacces-issues-with-npm-install/29787931#29787931 – Dmitri Zaitsev Jul 15 '19 at 06:20
1

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.

Jacopo
  • 130
  • 1
  • 1
  • 9
1

Following command work for me:

sudo npm i -g node-pre-gyp
wizzfizz94
  • 1,288
  • 15
  • 20
  • You should not need to `sudo npm` - it creates permanent permission problems: https://stackoverflow.com/a/29787502/1614973 – Dmitri Zaitsev Jul 15 '19 at 06:15
  • True, how so? Both npm commands seem to point to same program. ie. ``` which npm /usr/local/bin/npm sudo which npm /usr/local/bin/npm ``` – wizzfizz94 Apr 15 '20 at 04:32
1

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

vad nevod
  • 19
  • 1
1

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!

mbspark
  • 534
  • 3
  • 18
0

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

0

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

Dut A.
  • 1,029
  • 11
  • 22
0

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

That's worked for me.

Lucas Brogni
  • 129
  • 6
0

After uninstalling node-gyp, try installing again.

sudo npm uninstall -g node-gyp
sudo npm install -g node-gyp
myeongkil kim
  • 2,465
  • 4
  • 16
  • 22
kamalesh biswas
  • 883
  • 8
  • 9
0

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.

  • 1
    it does answer the question actually you can refer to this Github issue comment to check https://github.com/kelektiv/node.bcrypt.js/issues/868#issuecomment-1000835086 – Khaled Baghdadi Mar 31 '22 at 21:22
-1
npm ERR! bcrypt@1.0.3 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
kgangadhar
  • 4,886
  • 5
  • 36
  • 54
-2

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

kgangadhar
  • 4,886
  • 5
  • 36
  • 54