Comments (7)
This is the full error after changing the line endings:
> git commit -m "test"
/cygdrive/c/Program Files/nodejs/node
pre-commit:
pre-commit: Received an error while parsing or locating the `package.json` file:
pre-commit:
pre-commit: Cannot find module '\cygdrive\c\path\to\package.json'
pre-commit:
pre-commit: Skipping the pre-commit hook.
pre-commit:
It looks like it's failing on
Line 49 in f25888f
I am using Cygwin Git with a Windows Node installation. This makes sense to me, since Windows Node probably doesn't understand a non-Windows path.
Using "C:\Program Files\Git\bin\git" commit -m "test"
works for me, and surprisingly, with pre-commit
containing either line ending. Looks like Windows Git with Windows Node installation works out-of-the-box.
Hopefully this helps!
from pre-commit.
Same problem with babun on Windows 7, I got this when I try to commit :
: No such file or directory .git/hooks/pre-commit: line 2: ./node_modules/pre-commit/hook
: integer expression expected .git/hooks/pre-commit: line 4: [: 127
: numeric argument required .git/hooks/pre-commit: line 5: exit: 0
Hope we'll find a solution
from pre-commit.
Same here on Windows 10 in WSL Bash
from pre-commit.
Same on Windows 7
from pre-commit.
If you open up .git/hooks/pre-commit
, you can see that the code is written in bash:
#!/bin/bash
./node_modules/pre-commit/hook
RESULT=$?
[ $RESULT -ne 0 ] && exit 1
exit 0
Interestingly enough, I get the same message in Cygwin, but I don't in Git bash's mingw64.
In any case, the problem is probably something something doesn't understand bash.
Cygwin:
$ uname -r
2.10.0(0.325/5/3)
$ git --version
git version 2.16.2
Git bash:
$ git --version
git version 2.5.0.windows.1
from pre-commit.
EDIT: this is a red herring. See next comment for details.
Update: looks like .git/hooks/pre-commit
was not happy about the line ending. It had \r\n
(Windows). Switching to \n
got me further.
EDIT: looks like it purposely chooses Windows line ending (
Lines 104 to 108 in f25888f
I suspect the problems I am encountering are specific to Cygwin, so if you're not using Cygwin, give the above a shot.
from pre-commit.
In node_modules/pre-commit/index.js
change line
this.json = require(path.join(this.root, 'package.json'));
to
this.json = require(path.join(this.root, 'package.json').replace(/\\([a-zA-Z])\\/, '$1:\\'));
This will change \c\Users\rofrol\project1\package.json
to c:\Users\rofrol\project1\package.json
.
from pre-commit.
Related Issues (20)
- Add environment variable
- doesn't work with vue-cli v3.x HOT 1
- Error on windows commit (hook: line 49: : command not found) HOT 9
- Document how to turn this off permanently HOT 3
- install.js doesn't work with link file of .git.
- Question: Prevent pre-commit hook to continue on committing? HOT 5
- Does not find correct root. HOT 1
- Doesn't find git root when inside a submodule
- Commit f25888f doesnt seem to have been pushed to npm
- How to make pre-commit works just with npm ci?
- can't find any error detail HOT 1
- How to run pre-commit hook in docker container?
- make it compatible with yarn pnp
- [Bug] pre-commit don't work HOT 1
- pre-commit
- chmod 777 breaks CIS 6.1.10 (ensure no world writable files)
- [BUG] Install with --force Flag Overwrites pre-commit.old
- Is there any relationship with pre-commit.com?
- Package maintainance HOT 4
- pre-commit hook not working on macos
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pre-commit.