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

Add windows compatibility to npx simple-git-hooks when configured by .js file #38

Open
toplenboren opened this issue Mar 23, 2021 · 2 comments
Labels
question Further information is requested

Comments

@toplenboren
Copy link
Owner

toplenboren commented Mar 23, 2021

When setting the configuration from js file (simple-git-hooks.js or .simple-git-hooks.js)
the npx simple-git-hooks command executed on Windows 10 returns an error:

Line:       1
Char:      1
Error:      'module' is not defined
Source:  Microsoft JScript runtime error

The problem happens because for some reason Windows might use internal JS interpreter instead of node. This internal interpreter does not know what module is, thus throwing an error.

--

Possible workaround for now is to use configuration from package.json or simple-git-hooks.json files.

Also changing the default interpreter might help

@toplenboren toplenboren added the bug Something isn't working label Mar 23, 2021
@vltansky
Copy link

vltansky commented Apr 8, 2021

Hey, actually it did work for me today. I'm on windows 10 with configuration in .simple-git-hooks.js.
Here is PR if you want to check settings/deps/etc.: nolimits4web/swiper#4417

P.S Using bash if relevant

@XhmikosR
Copy link

XhmikosR commented May 1, 2022

The problem is that Windows doesn't support shebangs. So, running foo.js will use the default program associated with .js files, which is usually wscript. The solution is to use exec from Node.js and use node foo.js across the codebase.

@toplenboren toplenboren added question Further information is requested and removed bug Something isn't working labels Mar 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants