Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue while running scripty on windows10 #92

Open
vsawant1608 opened this issue Feb 5, 2021 · 7 comments
Open

Issue while running scripty on windows10 #92

vsawant1608 opened this issue Feb 5, 2021 · 7 comments

Comments

@vsawant1608
Copy link

I have below package.json file

{
  "name": "scripty-issue",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "dev": "node app.js",
    "foo": "scripty"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "cross-spawn": "^7.0.3",
    "express": "^4.17.1"
  },
  "devDependencies": {
    "scripty": "^2.0.0"
  },
  "scripty": {
    "logLevel": "verbose"
  }
}

and below is '/scripts/foo.sh'

echo "Hello";

When I run
npm run foo getting below error on windows.

internal/child_process.js:366
    throw errnoException(err, 'spawn');
    ^

Error: spawn UNKNOWN
    at ChildProcess.spawn (internal/child_process.js:366:11)
    at spawn (child_process.js:551:9)
    at module.exports (D:\Explore\scripty-issue\node_modules\scripty\lib\run\spawn-script.js:8:17)
    at cb (D:\Explore\scripty-issue\node_modules\scripty\lib\run\index.js:4:27)
    at D:\Explore\scripty-issue\node_modules\async\dist\async.js:3880:24
    at replenish (D:\Explore\scripty-issue\node_modules\async\dist\async.js:1011:17)
    at D:\Explore\scripty-issue\node_modules\async\dist\async.js:1016:9
    at eachOfLimit (D:\Explore\scripty-issue\node_modules\async\dist\async.js:1041:24)
    at D:\Explore\scripty-issue\node_modules\async\dist\async.js:1046:16
    at _parallel (D:\Explore\scripty-issue\node_modules\async\dist\async.js:3879:5)

Just works fine on ubuntu. Any pointers would be helpful. I tried passing {shell:true} in node_modules\scripty\lib\run\spawn-script.js:8:17 and it just worked fine.

@vsawant1608 vsawant1608 changed the title Issue while running scripty on windows Issue while running scripty on windows10 Feb 5, 2021
@GiancarlosIO
Copy link

Same here 😢

@magnus-bb
Copy link

Same here. Have tried clearing NPM cache and clearing out node_modules. Scripty exclaims that it can find the script and tries to execute it. The script is executable and works when run directly with bash.

@sanketphansekar
Copy link

sanketphansekar commented Feb 13, 2021

@vsawant1608 I feel the mistake might be in creating the script file, it should be with extension .cmd

As per documentation : In order to add Windows support, you could define scripts-win/script.cmd

For more details on windows support you can read it here

@dealvz
Copy link

dealvz commented Feb 21, 2021

@sanketphansekar followed those instructions, however what if the script is type #!/usr/bin/env node ?

@jonrcrowell
Copy link

jonrcrowell commented Feb 25, 2021

I was having the same issue regardless of how I configured the shebang. (node, cmd, pwsh, bash, whatever)
I also deleted node_modules, any .lock files I had, and re-ran yarn.

I was able to get it to work by running wsl from the terminal, then running my scripty script. I have both a /scripts folder and a /scripts-win folder. The version that gets called from the wsl prompt is the /scripts version, which I actually prefer so that I don't have to maintain two sets of scripts.

Unfortunately using wsl only gets past the initial events.js // Unhandled 'error'. My initial test script just had a console.log statement in it. When I added something that I actually want the script to do, it failed.

Changing my node scripts to .cmd files resolved all errors, but left me stuck with re-writing my scripts, which at this point isn't worth the trouble. I want to use JavaScript.

Issues like this make me seriously consider switching to a Mac for good.

@vsawant1608
Copy link
Author

vsawant1608 commented Jun 17, 2021

Just a hack for this would be to update file in node_modules to use cross_spawn(https://www.npmjs.com/package/cross-spawn). It makes most of the things work fine on windows without any issues.

image

@andredezzy
Copy link

Any news?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants