1

I am trying to run my Jasmine tests using Karma on the command line. I am running in Visual Studio, which seems to use Windows command prompt in its "terminal" window. I have a command which works in GitBash but not the Visual Studio Code terminal. This is the command I am trying to run:

node_modules/karma/bin/karma start karma.conf.js --single-run

The folder structure is correct - that is to say, I have a nested folder structure that matches node_modules/karma/bin, and I have a file at that location called karma.

I am starting from the same location in both instances. When I run this command in Visual Studio Code terminal, or windows command prompt, I get the following error: "'node_modules' is not recognized as an internal or external command, operable program or batch file."

But in GitBash, it works just fine.

It is very hard to come up with an appropriate google search term that describes what I am trying to do!

I have tried: - swapping forward slashes for back slashes - Enclosing things in quotes - Adding "./" to the start - using the run command

Can anybody help??

ClareSudbery
  • 391
  • 4
  • 11

1 Answers1

1

Fixed!

It turns out I needed to do a couple of things:

1) Install the karma command-line interface like this:

npm install -g karma-cli

2) Adjust my original command. By installing the command-line interface globally, this changed the path of the resulting karma file, from node_modules\karma\bin to node_modules\.bin.

So I had to run this to get it working:

node_modules\.bin\karma start karma.conf.js --single-run

ClareSudbery
  • 391
  • 4
  • 11
  • ok, if you did a google search specifically for `node_modules\.bin\karma start karma.conf.js --single-run` you would have found the answer here http://stackoverflow.com/questions/20800933/running-karma-after-installation-results-in-karma-is-not-recognized-as-an-inte – Gerhard May 19 '17 at 14:00
  • Hindsight is a wonderful thing! But I never would have put exactly that into a search engine, as it wasn't until I'd already solved the problem that I discovered the correct path was node_mules\.bin\karma - I was originally trying node_modules/karma/bin – ClareSudbery May 21 '17 at 15:57