npm install and test not working on windows (cmd.exe)

I am trying GitHub Actions with two different npm projects. Both appear to silently fail to run the tests on Windows, but run as expected on macOS and Ubuntu. The job seems to stop after the npm install. I have tried npm install and npm ci, I have tried adding –loglevel=error in case warnings in the output were the issue, I have tried npm install || exit 0.  I do not have a lot of experience with Windows scripting or Actions so suggestions welcome.

Note the install runs, but apparently not the subsequent echo or the tests. (The hash warning is from using yaml comment character in the run commands, and can be disregarded.)

I tried specifying

shell: powershell

 and that got me past the install. The npm test  failed in an opaque way without expected output, but at least I have a workaround for the first blocker of continuing past the npm install.

Discovered cmd.exe advice to prefix calls with call if running a script rather than an executable. Switching back to cmd.exe and prefxing all npm commands with call and…

Success! Well, somewhat. The GitHub Action did run the install and then the tests. But ignored the tests failing. Progress…

call npm install
call npm run test

I have things working properly on Windows after switching away from multiline run command. e.g.

- name: npm install
      run: npm ci
    - name: test
      run: npm run test

Don’t know if the other problems I hit were bugs or user error, but I am unblocked.


I am seeing the same issue myself with your resolution being the only I’ve figured out as well. Unfortunately that becomes painful in larger cases with os matrixes.

Still seeing issues with windows-2016 as well 

 just check using git bash whether npm -v is exeuted or not.

If npm is working in git bash , then its not path problem…your path reference is ok.

go to environment variable-> system vaiable

just check ComSpec : %SystemRoot%\system32\cmd.exe  is correct or not

in many cases if you have a slash in the end it will not work .for example 

ComSpec : %SystemRoot%\system32\cmd.exe\

in such case remove the slash if it exists at the end.

Otherwise check where does your cmd.exe locate and then put that path in ComSpec

Usually it resides at c://Windows/System32/cmd.exe

I hope it works. 



Thanks for the reply, but I don’t think you understand the context. The commands are running in a GitHub Action in the cloud. The npm install worked, but the following commands did not run.