Giter VIP home page Giter VIP logo

Comments (6)

y0hnn avatar y0hnn commented on June 29, 2024 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.

rosskevin avatar rosskevin commented on June 29, 2024

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.

rosskevin avatar rosskevin commented on June 29, 2024

@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.

tristanbbq avatar tristanbbq commented on June 29, 2024

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.

buglovebug avatar buglovebug commented on June 29, 2024

I just encountered the same, the reason is default shell not zsh, use chsh -s to change default shell to zsh

from pre-commit.

uzprocode avatar uzprocode commented on June 29, 2024

▶ 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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.