Windows npm run script shell
Skill JinNing6/Noosphere/shared_skills/releases/1.0.0/windows-npm-run-script-shell
Use when Windows npm run, npm test, npm run build, or npm run-script exits before running the script with ERR_INVALID_ARG_TYPE, "file argument must be of type string", missing ComSpec, broken script-shell, stripped CLI flags, sandboxed npm cache/log EPERM, or silent npm script output.From its SKILL.md
npx -y skills add JinNing6/Noosphere --skill windows-npm-run-script-shellAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 18 stars18 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
2.8 KB, 630 tokens by cl100k_base, as published. Nobody here has run it
Windows Npm Run Script Shell
Overview
Windows npm scripts need a shell. If ComSpec is missing or npm cannot infer a script shell, npm run ... can fail inside npm before tsc, Vite, Vitest, or Playwright actually runs.
Triage
Use this flow before changing app code:
- Run the target tool directly with
npx, for examplenpx tsc -b --pretty false,npx vite build, ornpx vitest run. - Run
npm run <script> --loglevel verbose. - Open the npm debug log if output is empty.
- Check shell config:
npm config get script-shell
npm config get cache
npm config get update-notifier
Write-Host "ComSpec=[$env:ComSpec]"
Write-Host "SHELL=[$env:SHELL]"
If direct npx commands pass but npm run fails with ERR_INVALID_ARG_TYPE: The "file" argument must be of type string. Received undefined, treat it as npm shell configuration, not a project build failure.
If direct node <script> succeeds but npm test/npm run exits silently in a sandbox, rerun with --loglevel verbose. When npm reports EPERM creating %LocalAppData%\npm-cache\_logs or attempts registry access only for update checks, treat it as npm runtime side effects, not a test failure.
Fix
Prefer a project-local .npmrc so the fix travels with the repo:
script-shell=C:\Windows\System32\cmd.exe
For sandboxed Windows workspaces where npm cannot write the user cache/log directory, keep npm side effects inside the repo and disable network-prone notices:
cache=.npm-cache
update-notifier=false
fund=false
audit=false
script-shell=cmd.exe
Then rerun:
npm run build
npm test -- --run
If the project requires PowerShell syntax in scripts, set script-shell to PowerShell and avoid && in package scripts, because Windows PowerShell 5 does not support &&.
Common Mistakes
- Do not rewrite TypeScript, Vite, Vitest, or React code when
npx <tool>succeeds and onlynpm runfails. - Do not treat silent npm output as proof that the build tool produced no diagnostics; inspect the npm debug log.
- Do not ignore npm cache/log
EPERMin sandboxed workspaces; set a project-local cache before escalating. - Do not set a global npm config unless the user asked for machine-wide changes.
- Do not assume
SHELLreplacesComSpecfor npm on Windows.
Completion Standard
The issue is fixed only when:
- The original
npm run <script>command succeeds. - The direct tool command still succeeds.
- Tests/builds that previously passed via
npxalso pass through npm scripts.
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.