Answers: <p>One possible issue is that the NVM install script only writes the commands to set itself up to either .bash_profile OR .bashrc. Depending on your systems configuration, it may only be setup for interactive shells, not ones spawned by other programs (more info). Sourcing the nvm setup script can be a good option, as a previous comment noted. If you have a number of commands to run for 1 make target, look into .ONESHELL. Sourcing $NVM_DIR/nvm.sh should take care of it.</p>
  <p>Another option that invokes bash directly with the interactive flag might work as well.</p>
  
Answers: CC BY-SA 4.0
Answers: 2020-08-06T06:48:11.397Z
Answers: 2020-08-06T06:48:11.397Z
Answers: Turnip
Body: <p>If I need to use something like NVM in my makefile, I run into a problem, because NVM exports some bash functions that are not available in Make, even if my shell is defined as bash in the makefile.</p>
  <p>How do I cause make to &quot;inherit&quot; all the parent shell's functions? Is there a way to make NVM accessible to a makefile, without writing export -f for a zillion little NVM bash functions?</p>
  
Tags: <bash><make>
Title: How can I use bash functions in makefile?
UserDisplayName: Joseph
ThreadText: # How can I use bash functions in makefile?
  
  (Asked by: username_0 on 2020-08-06)
  
  If I need to use something like NVM in my makefile, I run into a problem, because NVM exports some bash functions that are not available in Make, even if my shell is defined as bash in the makefile.
  
  How do I cause make to "inherit" all the parent shell's functions? Is there a way to make NVM accessible to a makefile, without writing export -f for a zillion little NVM bash functions?
  
  **Tags:** bash, make
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-08-06. Score: 2 | Accepted answer
  
  One possible issue is that the NVM install script only writes the commands to set itself up to either .bash\_profile OR .bashrc. Depending on your systems configuration, it may only be setup for interactive shells, not ones spawned by other programs (more info). Sourcing the nvm setup script can be a good option, as a previous comment noted. If you have a number of commands to run for 1 make target, look into .ONESHELL. Sourcing $NVM\_DIR/nvm.sh should take care of it.
  
  Another option that invokes bash directly with the interactive flag might work as well.
  
  
  ---
  
  