PunDefeated
PunDefeated

Reputation: 596

WebStorm mocha test 'sh' is not recognized as an internal or external command

I'm trying to run a mocha test for my node.js code which runs the following line:

exec(`sh ${scriptFile}`);

When I run it from the command line (Git Bash) using npm test, it passes. However, when I run it from WebStorm I get the following error:

'sh' is not recognized as an internal or external command,
operable program or batch file.

I feel like I'm probably missing some WebStorm setting, but I can't figure out what it is. Any ideas?

P.S. I'm on Windows.

Upvotes: 3

Views: 6183

Answers (2)

vahob
vahob

Reputation: 111

For those who are using phpStorm on Windows and come here by Google

Install Git on your machine. Go to Settings/Terminal and set shell path to C:\Program Files\Git\bin\sh.exe

Also add C:\Program Files\Git\bin to your PATH in environment variables.

Upvotes: 3

Will Barnwell
Will Barnwell

Reputation: 4089

Git Bash implements a *nix-esque shell simulating bash which can parse your command. Webstorm appears to be trying to execute your command in either powershell or cmd, which do not support sh syntax.

Open the Terminal page of the Settings/Preferences dialog, and configure the Shell path field as follows:

"[path to the git installation]\bin\sh.exe" -login -i

This will probably be "C:\Program Files\Git\bin\sh.exe" -login -i

Source: https://www.jetbrains.com/help/webstorm/2017.1/working-with-embedded-local-terminal.html

Upvotes: 1

Related Questions