4

Tried to install Karma

npm install -g karma

A warning is produced

npm WARN optional dep failed, continuing fsevents@0.3.5

At the end it seems there is no Karma installed

karma init karma.config.js
'karma' is not recognized as an internal or external command (so a windows installation).

However there seems to be a karma in

C:\Users\Me\AppData\Roaming\npm\node_modules\karma

and a builerror.log file

gyp ERR! configure error 
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
gyp ERR! stack     at failNoPython (c:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:103:14)
gyp ERR! stack     at c:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:64:11
gyp ERR! stack     at Object.oncomplete (evalmachine.<anonymous>:108:15)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "node" "c:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd  C:\Users\Me\AppData\Roaming\npm\node_modules\karma\node_modules\socket.io\node_modules\socket.io-client\node_modules\ws
gyp ERR! node -v v0.10.36
gyp ERR! node-gyp -v v1.0.1
gyp ERR! not ok 

Do I need to install python in order to work with karma or is something else wrong? Thanks in advance for any help!

Gerard
  • 2,649
  • 1
  • 28
  • 46

2 Answers2

6

You need to install the command line interface so that karma will be recognised:

npm install -g karma-cli

Karma Installaltion Guide

The node-gyp error is because python isn't installed. To avoid that error follow the following steps:

  • Install python (v2.7.10 recommended, v3.x.x is not supported): http://www.python.org/getit/windows/
  • Make sure that you have a PYTHON environment variable, and it is set to drive:\path\to\python.exe not to a folder
  • Install Visual Studio

Windows XP/Vista/7: - Microsoft Visual Studio C++ 2013 (Express version works well) - If the install fails, try uninstalling any C++ 2010 x64&x86
Redistributable that you have installed first - If you get errors that the 64-bit compilers are not installed you may also need the compiler update for the Windows SDK 7.1

Windows 7/8: - Microsoft Visual Studio C++ 2013 for Windows Desktop (Express version works well)

Windows 10: - Install Visual Studio Community 2015 Edition. (Custom Install, Select Visual C++ during the installation) - Set the environment variable GYP_MSVS_VERSION=2015 - Run the command prompt as Administrator

If the above steps have not worked or you are unsure please visit http://www.serverpals.com/blog/building-using-node-gyp-with-visual-studio-express-2015-on-windows-10-pro-x64 for a full walkthrough

All Windows Versions - For 64-bit builds of node and native modules you will also need the Windows 7 64-bit SDK

You may need to run one of the following commands if your build complains about WindowsSDKDir not being set, and you are sure you have already installed the SDK:

call "C:\Program Files\Microsoft SDKs\Windows\v7.1\bin\Setenv.cmd" /Release /x86
call "C:\Program Files\Microsoft SDKs\Windows\v7.1\bin\Setenv.cmd" /Release /x64

Source: node-gyp Github

Wayne Ellery
  • 7,888
  • 1
  • 28
  • 45
  • I still see the same issue even after installing the cli. The documentation says to do npm install karma --save-dev first anyway... still looking for a solution here. – JD Smith Aug 20 '15 at 14:07
  • Yes. If you install Karma but don't install the cli you will get 'karma' is not recognized as an internal or external command. If you don't do this you will need to run Karma by using `./node_modules/karma/bin/karma`. Also check your path variable on windows to make sure it includes the the npm global package path. – Wayne Ellery Aug 20 '15 at 14:11
  • 3
    But answer to original question about Python error is not solved ! – Dejo Oct 05 '15 at 18:36
  • Why is this the accepted answer? It has noting to do with the question asked. – RajV Jan 06 '16 at 20:07
  • @RajV How so? The reason for `'karma' is not recognized as an internal or external command` is because `npm install -g karma-cli` wasn't run. – Wayne Ellery Jan 06 '16 at 21:08
  • In this case installation of Karma had failed because of the node-gyp issue. That needs to be fixed first. In addition, as you have noted, karma-cli needs to be installed globally for the karma command to be available. – RajV Jan 07 '16 at 14:50
  • @RajV That node-gyp is a warning. You can still run karma without node-gyp installed. To install node-gyp you need to install python. Follow the steps here: http://stackoverflow.com/a/21366601/368997 – Wayne Ellery Jan 07 '16 at 21:02
  • In some cases the node-gyp issue completely hobbles Karma. Even after you install karma-cli if you run the karma command it fails with runtime error. I had to basically update my Node install and reinstalled karma and karma-cli. This solved the node-gyp problem. Now karma works fine. – RajV Jan 08 '16 at 16:00
2

Reference from https://stackoverflow.com/a/21366601/368997.
Karma requies node-gyp, and node-gyp has its own dependence (from the github). Especially Windows, you need python and make sure that you have a PYTHON environment variable.

Community
  • 1
  • 1
Chayapol
  • 3,718
  • 1
  • 21
  • 12