NodeJS - Error installing with NPM

node.jsNpm

node.js Problem Overview


Microsoft Windows [Version 6.3.9600]
(c) 2013 Microsoft Corporation. All rights reserved.

C:\Windows\system32>npm install caress-server
npm http GET https://registry.npmjs.org/caress-server
npm http 304 https://registry.npmjs.org/caress-server
npm http GET https://registry.npmjs.org/jspack/0.0.1
npm http GET https://registry.npmjs.org/buffertools
npm http 304 https://registry.npmjs.org/jspack/0.0.1
npm http 304 https://registry.npmjs.org/buffertools

> buffertools@2.0.1 install C:\Windows\system32\node_modules\caress-server\node_
modules\buffertools
> node-gyp rebuild


C:\Windows\system32\node_modules\caress-server\node_modules\buffertools>node "G:
\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-
gyp.js" rebuild
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYT
HON env variable.
gyp ERR! stack     at failNoPython (G:\nodejs\node_modules\npm\node_modules\node
-gyp\lib\configure.js:101:14)
gyp ERR! stack     at G:\nodejs\node_modules\npm\node_modules\node-gyp\lib\confi
gure.js:64:11
gyp ERR! stack     at Object.oncomplete (fs.js:107:15)
gyp ERR! System Windows_NT 6.2.9200
gyp ERR! command "node" "G:\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\
bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Windows\system32\node_modules\caress-server\node_modules\buffert
ools
gyp ERR! node -v v0.10.25
gyp ERR! node-gyp -v v0.12.2
gyp ERR! not ok
npm ERR! buffertools@2.0.1 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the buffertools@2.0.1 install script.
npm ERR! This is most likely a problem with the buffertools package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls buffertools
npm ERR! There is likely additional logging output above.

npm ERR! System Windows_NT 6.2.9200
npm ERR! command "G:\\nodejs\\\\node.exe" "G:\\nodejs\\node_modules\\npm\\bin\\n
pm-cli.js" "install" "caress-server"
npm ERR! cwd C:\Windows\system32
npm ERR! node -v v0.10.25
npm ERR! npm -v 1.3.24
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     C:\Windows\system32\npm-debug.log
npm ERR! not ok code 0

C:\Windows\system32>

I am installing a certain NodeJS script - Caress. But i am not unable to. I am using Windows 8.1, can anyone tell me what is the problem i am facing, and why is this installation not working. There seems to be a problem with the buffertools dependency, thats far as i can think. Dont know how maybe fix this?

If i download the build from github and place it in node-modules, nothing seems to work. when i try to start, using npm start, or during implementation either.

G:\nodejs\node_modules\caress-server>npm install

G:\nodejs\node_modules\caress-server>npm start

> caress-server@0.1.1 start G:\nodejs\node_modules\caress-server
> node examples/server.js

   info  - socket.io started

module.js:340
    throw err;
          ^
Error: Cannot find module './build/Release/buffertools.node'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (G:\nodejs\node_modules\caress-server\node_modules\buf
fertools\buffertools.js:16:19)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)

npm ERR! caress-server@0.1.1 start: `node examples/server.js`
npm ERR! Exit status 8
npm ERR!
npm ERR! Failed at the caress-server@0.1.1 start script.
npm ERR! This is most likely a problem with the caress-server package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node examples/server.js
npm ERR! You can get their info via:
npm ERR!     npm owner ls caress-server
npm ERR! There is likely additional logging output above.
npm ERR! System Windows_NT 6.2.9200
npm ERR! command "G:\\nodejs\\\\node.exe" "G:\\nodejs\\node_modules\\npm\\bin\\n
pm-cli.js" "start"
npm ERR! cwd G:\nodejs\node_modules\caress-server
npm ERR! node -v v0.10.25
npm ERR! npm -v 1.3.24
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     G:\nodejs\node_modules\caress-server\npm-debug.log
npm ERR! not ok code 0

G:\nodejs\node_modules\caress-server>

node.js Solutions


Solution 1 - node.js

As commented below you may not need to install VS on windows, check this out

https://github.com/nodejs/node-gyp/issues/629#issuecomment-153196245

UPDATED 02/2016

Some npm plugins need node-gyp to be installed.

However, node-gyp has it's own dependencies (from the github page):

enter image description here

UPDATED 09/2016

If you're using Windows you can now install all node-gyp dependencies with single command (NOTE: Run As Admin in Windows PowerShell):

 $ npm install --global --production windows-build-tools

and then install the package

 $ npm install --global node-gyp
UPDATED 06/2018

https://github.com/nodejs/node-gyp/issues/809#issuecomment-155019383

>Delete your $HOME/.node-gyp directory and try again.

See full documentation here: node-gyp

Solution 2 - node.js

Make sure you have all the required software to run node-gyp:

You can configure version of Visual Studio used by node-gyp via an environment variable so you can avoid having to set the --msvs_version=2012 property every time you do an npm install.

Examples:

  • set GYP_MSVS_VERSION=2012 for Visual Studio 2012
  • set GYP_MSVS_VERSION=2013e (the 'e' stands for FREE 'express edition')

For the full list see

This is still painful for Windows users of NodeJS as it assumes you have a copy of Visual Studio installed and many end users will never have this. So I'm lobbying Joyent to the encourage them to include web sockets as part of CORE node and also to possible ship a GNU gcc compiler as part of NodeJS install so we can permanently fix this problem.

Feel free to add your vote at:

Solution 3 - node.js

I encountered the issue with the error:

gyp ERR! configure error

gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.

Here is what I was doing and what finally worked.

Disclaimer: I am just getting my hands into Node, Angular after many years in the Java, Linux world among others...

Environment Description: Windows 8.1 64-bit; Cygwin; cygwin bash shell

Command used that led to error: npm install -g karma

Error: gyp ERR! configure error gyp ERR! stack Error: Can't find Python executable "python", you can set the PYT HON env variable.

Discovery: 'which python' on bash shell clearly shows '/usr/bin/python'. Now that is annoying!

Solution: This is only applicable to those using the environment similar to what I have, i.e. using cygwin and bash shell. Hope it helps in other environments as well but keep in mind that your kettle of tea may look a little different than mine.

  1. Firstly, need to set the $PYTHON shell env variable in .bashrc using the explicit windows path to the python executable and not the unix like root path (/usr/bin) used by cygwin.
  2. Secondly, and this one took a lot of trial/error and here's the gotcha! Cygwin installs python under /usr/bin (which is really a mirror of /bin on windows) with the version, i.e. (in my system) /usr/bin/python2.7.exe and then adds a link /usr/bin/python --> python2.7.exe. The problem is that gyp cannot follow this link and keeps giving the annoying error that it cannot find python even though you can find it just fine from the shell command line.
  3. With the above background now add the following line to your .bashrc

export PYTHON="C:/cygwin64/bin/python2.7.exe (or whatever is the version on your system)"

  1. Now source your .bashrc from your home directory (on cygwin)--> 'source .bashrc'

You should be fine now and gyp will find the python executable.

I hope this helps someone stumbling on the same or similar issue.

Solution 4 - node.js

should be able get all node-gyp dependencies with chocolatey for Windows

choco install python2
choco install visualstudioexpress2013windowsdesktop

Solution 5 - node.js

Setup JavaScript Environment

1. Install Node.js

Download installer at NodeJs website. You can download the latest V6

2. Update Npm

Npm is installed together with Node.js. So don't worry.

3. Install Anaconda

Anaconda is the leading open data science platform powered by Python. The open source version of Anaconda is a high performance distribution of Python. It can help you to manage your python dependency. You can use it to create different python environment in the futher if you want to touch with it.

> Node-gyp only support >= Python 2.7 and < Python 3.0

> So just install the 2.7 version

4. Install Node-gyp

You can install with npm:

$ npm install -g node-gyp

You will also need to install:

  • On Windows:

    • Option 1: Install all the required tools and configurations using Microsoft's windows-build-tools using npm install --global --production windows-build-tools from an elevated PowerShell or CMD.exe (run as Administrator).

    • Option 2: Install tools and configuration manually:

      • Visual C++ Build Environment:

        • Option 1: Install Visual C++ Build Tools using the Default Install option.
        • Option 2: Install Visual Studio 2015 (or modify an existing installation) and select Common Tools for Visual C++ during setup. This also works with the free Community and Express for Desktop editions.

        >  [Windows Vista / 7 only] requires .NET Framework 4.5.1

      • Launch cmd, npm config set msvs_version 2015

    If the above steps didn't work for you, please visit Microsoft's Node.js Guidelines for Windows for additional tips.

If you have multiple Python versions installed, you can identify which Python version node-gyp uses by setting the '--python' variable:

$ node-gyp --python C:/Anaconda2/python.exe

If node-gyp is called by way of npm and you have multiple versions of Python installed, then you can set npm's 'python' config key to the appropriate value:

$ npm config set python C:/Anaconda2/python.exe

Future update for Node.js and npm

Download installer from their official website and direct install it. The installer will automatic help you to remove old files.

npm update npm

Future update for Python

conda update --all

Solution 6 - node.js

> gyp ERR! configure error gyp ERR! stack Error: Can't find Python > executable "python", you can set the PYT HON env variable.

This means the Python env. variable should point to the executable python file, in my case: SET PYTHON=C:\work\_env\Python27\python.exe

Solution 7 - node.js

For Cygwin users:

The python issue with using npm on an out-of-the-box Cygwin installation, is that node-gyp is giving a misleading error due to incomplete checking in the ../npm/node_modules/node-gyp/lib/configure.js code.

It's due to how Cygwin treats symbolic links. It doesn't do that properly in an out-of-the box installation. So the error messages from the above code become misleading, as it complains about the PYTHON path and not the existence of python.exe (or link of) file itself.

There are (at least) 2 ways to resolve this.

  1. Installing the Cygwin package cygutils-extra and use winln.
  2. Use native Windows CMD in Admin mode.

For (1) you can create a proper symlink from within Cygwin shell by doing these steps:

# To make the Cygwin environment treat Windows links properly: 
# Alternatively add this to your `.bashrc` for permanent use.
export CYGWIN=winsymlinks:nativestrict

# Install Cygwin package containing "winln"
apt-cyg install cygutils-extra

# Make a proper Windows sym-link:
cd /cygdrive/c/cygwin64/bin/
winln.exe -s python2.7.exe python.exe

# Add PYTHON as a native Windows system wide variable (HKLM) 
setx /M PYTHON "C:\cygwin64\bin\python"

(Also assuming you are running the Cygwin shell as Admin.) Using apt-cyg is recommended and can be found in various forms on github.


For (2) the resolution for out-of-the-box Cygwin users is this:

# Open a native Windows CMD in Administrator mode and:
cd C:\cygwin64\bin\
mklink python.exe python2.7.exe

The result should look like this:

C:\cygwin64\bin>ls -al python*
lrwxrwxrwx 1 xxx            xxx   13 Jun  2  2015 python -> python2.7.exe
lrwxrwxrwx 1 Administrators xxx   13 Aug 24 17:28 python.exe -> python2.7.exe
lrwxrwxrwx 1 xxx            xxx   13 Jun  2  2015 python2 -> python2.7.exe
-rwxr-xr-x 1 xxx            xxx 9235 Jun  2  2015 python2.7.exe

Solution 8 - node.js

For windows

Check python path in system variable. npm plugins need node-gyp to be installed.

open command prompt with admin rights, and run following command.

npm install --global --production windows-build-tools

npm install --global node-gyp

Solution 9 - node.js

Fixed with downgrading Node from v12.8.1 to v11.15.0 and everything installed successfully

Solution 10 - node.js

I was working on an old Vue 2.x project, at least 2 years old and deps were never updated. Reverting to Node v10.16.3 worked for me. Versions 14 and 12 did not work.

Solution 11 - node.js

for me the solution was:

rm -rf  ~/.node_gyp and
sudo npm install -g [email protected]
cd /usr/local/lib sudo ln -s ../../lib/libSystem.B.dylib libgcc_s.10.5.dylib 
brew install gcc
npm install

Solution 12 - node.js

I was installing appium by npm install -g appium and getting the same error on Windows 10.

Below command worked for me:

npm --add-python-to-path='true' --debug install --global windows-build-tools

https://github.com/felixrieseberg/windows-build-tools/issues/33

Solution 13 - node.js

The question is already answered but these were not working in my case which is alpine Linux based OS so maybe this helps someone else.

I was also getting same error

gyp ERR! configure error 
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.

So fix by single line just add this if you are working in Dockerfile or install it in OS

apk add --no-cache python nodejs

in ubuntu

sudo apt-get install python3.6

Note: Node version:8

Solution 14 - node.js

install node-gyp and c++ compiler (gcc-c++).

Solution 15 - node.js

npm install --global --production windows-build-tools

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
QuestionShaurya ChaudhuriView Question on Stackoverflow
Solution 1 - node.jsIlan FrumerView Answer on Stackoverflow
Solution 2 - node.jsTony O'HaganView Answer on Stackoverflow
Solution 3 - node.jsAndyView Answer on Stackoverflow
Solution 4 - node.jstarikakyolView Answer on Stackoverflow
Solution 5 - node.jsYoongKang LimView Answer on Stackoverflow
Solution 6 - node.jsY. AliakseiView Answer on Stackoverflow
Solution 7 - node.jsemigenixView Answer on Stackoverflow
Solution 8 - node.jsMahesh GudadariView Answer on Stackoverflow
Solution 9 - node.jsMakView Answer on Stackoverflow
Solution 10 - node.jsAleksandar BencunView Answer on Stackoverflow
Solution 11 - node.jsOrrView Answer on Stackoverflow
Solution 12 - node.jshemantoView Answer on Stackoverflow
Solution 13 - node.jsAdiiiView Answer on Stackoverflow
Solution 14 - node.jsbrajesh jaishwalView Answer on Stackoverflow
Solution 15 - node.jsElialber LopesView Answer on Stackoverflow