Why does running npm test result in: '.' is not recognized as an internal or external command, operable program or batch file.? - windows

I have the following installed:
Windows 10
Git bash (mingw64)
Node.js v8.7.0
npm version 5.4.2
Packages:
chai 4.4.1
mocha 3.5.0
I have a sample mocha test that will always pass when it actually runs.
The command I'm running in my shell:
npm test
Output:
./node_modules/mocha/bin/_mocha
'.' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! Test failed. See above for more details.
For some reason I'm able to run this command directly:
./node_modules/mocha/bin/_mocha
Which results in
Sample Test
√ passes!
1 passing (4ms)
I'm guessing this has something to do with the weirdness of using a bash-like shell inside of windows, however I'm not sure how I can troubleshoot this from here.
Why might this error be happening, and is there a way to get 'npm test' to work properly without having to ditch using this windows programming environment?
Thanks & Regards

This may not be a perfect answer, but it fixes the issue in a way that is sufficient to continue developing:
in my package.json file I had:
"test" : "./node_modules/mocha/bin/_mocha"
Changing this to:
"test" : "node ./node_modules/mocha/bin/_mocha"
Made it so I could run npm test command fine.
I'm still unsure as to why the original value would not work since running that as a command in the shell works just fine.
If anyone sees this and wants to offer some insight that would be greatly appreciated.

Related

zsh: command not found: hiptest-publisher

I'm using hiptest-publisher in order to push test results on the cucumber studio platform. The tests run and pass.
I installed Ruby and then ran gem install hiptest-publisher.
When I try to run this command to push the test execution result back to Cucumber Studio:
hiptest-publisher --config-file=<path> --push="target/cucumber.json" --push-format=cucumber-json --test-run-id=123
I receive this error:
Any advice to solve this problem is welcome.
Thanks a lot!
Problem solved!
How did I solve it?
Step 1
$ gem environment
Will tell you the EXECUTABLE DIRECTORY.
Step 2
Put whatever that value is in your PATH in your .bashrc or other shell config file.
export PATH="$PATH:/path/to/bin"
Thank you!

Cloudflare Wrangler Installation

I am currently using MacOS and am trying to install wrangler using npm i #cloudflare/wrangler -g .
It tells me that Wrangler was installed correctly, but when I attempt to use wrangler it tells me zsh: command not found: wrangler.
How can I fix this?
Thank you
Have you solved your problem?
First of all: npm adds to $PATH the folder with binaries or scripts to launch them.
In windows it's ~\AppData\Roaming\npm, on linux it's /tools/node/bin etc.
Check your $PATH variable for something like "node" or "npm" or run 'npm list -g --depth=0' - the path to target location will be on first line of output.
If other globally installed packages works fine then check if npm folder contain any script related to wrangler. Maybe the problem is that wrangler was not installed correctly and related script was not added. Then try to reinstall. Or probably you can write this script by yourself.
Finaly note that wrangler binary(not script to launch it) is installed to ~/.wrangler folder (according to node_modules/#cloudflare/wrangler/binary.js)
If you will try to make your own script to run that you need:
run npm list -g --depth=0 and get the path from first line of output
find there node_modules
run cd node_modules/#cloudflare/wrangler
make sure that running node run-wrangler.js will not throw any errors (output is just wrangler "how to use")
if any errors occurs: try to node install-wrangler.js - this should download wrangler binary to ~/.wrangler and retry step 4
when everything is ready, go to path where scripts for globally installed packages located and add here your script which will at least run command node /path/to/the/run-wrangler.js and passing your args to it.

Undefined Step Definitions when Running Cucumber scripts in command line

I was previously using RubyMine to run cucumber test scripts and it works just fine, but I am looking for an alternative to run those scripts from command line.
When I try to run a specific .feature file from cmd, I get an error stating that my Ruby step definitions are undefined. I am assuming this is because they are not located in the same directory as the .feature file that I am trying to run.
Here is my cmd output:
Undefined Steps error output
Any suggestions welcome! Thanks
If you're running cucumber from your_directory. Then your .feature files should be in your_directory/features and step definitions (.rb files) in your_directory/features/step_definitions Subfolders are supported.
Look at https://docs.cucumber.io/guides/10-minute-tutorial/
If you're running Win10, check WSL - makes your life better ;-)

OS-independent grunt script command in NPM package.json

When the command grunt is run in a Windows shell in the same path as the grunt.js file, Windows opts to run grunt.js using the Windows Script Host. The recommended path is to explicitly call grunt.cmd.
That's all fine and dandy, but what can I do if I want to create an OS-independent script command in my NPM package.json? I can't do this if I want to also run in *nix:
"scripts": {
"dox": "grunt.cmd dox"
}
Any pointers? Or, is there a big piece of the puzzle that I'm missing? (I'm equally new to both NPM and Grunt).
I've found the solution in creating a grunt.bat file that just calls grunt.cmd:
#grunt.cmd %*
Therefore, on Windows, just invoking grunt triggers the batch file since it gets higher priority than Windows Scripting Host's picking up of grunt.js. On Linux, the regular grunt binary gets picked up. This works cross-platform for me now.
I've got the same problem: when there is tslint.js file in the root dir of the package and an npm script in package.json just calls tslint, jscript is fired by npm instead of node, resulting in "Microsoft JScript compilation error" popup.
A workaround is removing .JS from PATHEXT environment variable.

Running Expresso TDD in Node.js on Windows

Has anyone been able to get this to work?
Environment:
Windows 7 64-bit
node.js v0.6.7
npm 1.1.0-beta-10
expresso 0.9.2
I've successfully installed via npm from zip download (after modifying package.json to remove node-jscoverage dependence). 'npm ls' lists expresso as installed. After overcoming the problem described here by commenting out the reference to SIGINT, expresso will execute from cmd window. However, when I actually attempt to run test suites, I get a 'Cannot find module' error when it tries to open the first test suite. Any help would be appreciated.
You'll have to install the module locally, too.
Have you considered using mocha? It's supposed to be expresso's successor, written by the same author.

Resources