Comments (6)
I had the issue for days, and found out that I did not have the path for node bin set in my .zshrc.
I just needed to add : export PATH="/usr/local/bin:$PATH"
from pre-commit.
I have the same issue with zsh
, though slightly different setup, I use tower
. Recently I blew away all my node/npm/n installations, and reinstalled n
.
./node_modules/pre-commit/hook: line 49: : command not found
./node_modules/pre-commit/hook: line 49: : command not found
./node_modules/pre-commit/hook: line 51: shell_session_update: command not found
This works fine, so I don't see why the hook
is failing:
~ ❯❯❯ which node
/Users/kross/n/bin/node
~ ❯❯❯ node -v
v8.1.0
I can also execute the hook.
From in the project:
./node_modules/pre-commit/hook
No errors!
From outside the project (I expect problems, but it finds node):
❯❯❯ ./projects/ui/node_modules/pre-commit/hook
module.js:487
throw err;
^
Error: Cannot find module 'pre-commit'
at Function.Module._resolveFilename (module.js:485:15)
at Function.resolve (internal/module.js:18:19)
at [eval]:1:21
at ContextifyScript.Script.runInThisContext (vm.js:44:33)
at Object.runInThisContext (vm.js:116:38)
at Object.<anonymous> ([eval]-wrapper:6:22)
at Module._compile (module.js:569:30)
at evalScript (bootstrap_node.js:432:27)
at startup (bootstrap_node.js:139:9)
at bootstrap_node.js:575:3
So, I don't have any idea why within tower
it is having a problem. I can which node
anywhere...
I added set -x
and see that it cannot find node:
++ which node
++ which nodejs
++ which iojs
+ HAS_NODE=
+ [[ -z '' ]]
+ source_home_file .bash_profile
+ file=/Users/kross/.bash_profile
+ [[ -f /Users/kross/.bash_profile ]]
+ source /Users/kross/.bash_profile
++ [[ -s /Users/kross/.profile ]]
++ source /Users/kross/.profile
...
++ which node
+ NODE=
++ which nodejs
+ NODEJS=
++ which iojs
+ IOJS=
+ LOCAL=/usr/local/bin/node
+ BINARY=
+ [[ -n '' ]]
+ [[ -n '' ]]
+ [[ -n '' ]]
+ [[ -x /usr/local/bin/node ]]
+ [[ '' == *--dry-run* ]]
++ '' -e 'console.log(require.resolve('\''pre-commit'\''))'
./node_modules/pre-commit/hook: line 54: : command not found
+ '' ''
./node_modules/pre-commit/hook: line 54: : command not found
+ shell_session_update
./node_modules/pre-commit/hook: line 56: shell_session_update: command not found
from pre-commit.
@tauren I found my problem by adding set -x
to the script. I had an old ~/.bash_profile
lingering.
e.g.
+ source_home_file .bash_profile
+ file=/Users/kross/.bash_profile
+ [[ -f /Users/kross/.bash_profile ]]
+ source /Users/kross/.bash_profile
++ [[ -s /Users/kross/.profile ]]
++ source /Users/kross/.profile
The moment I rm ~/.bash_profile
, tower
executed properly.
from pre-commit.
Had same issue with sourcetree where pre-commit hook would fail and prevent me from committing in the client. Added /usr/local/bin
to path as mentionned by @yohannprigent and it fixed it. thanks!
from pre-commit.
I just encountered the same, the reason is default shell not zsh, use chsh -s to change default shell to zsh
from pre-commit.
▶ whereis brew
brew: /opt/homebrew/bin/brew /opt/homebrew/share/man/man1/brew.1
I just needed to add : export PATH="/opt/homebrew/bin:$PATH" in my '.zshrc'.
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.