title: "sh: node: command not found error" in npm postinstall in zsh
body: <p>I use <code>zsh</code> as the default command-line shell. I have installed <code>node</code> using <code>nvm</code>.</p>
  <p>When I try to install GatsbyJS I get an error</p>
  <pre><code>npm i -g gatsby-cli
  ....
  npm ERR! code 127
  npm ERR! path /Users/username/~/.nvm/versions/node/v16.0.0/lib/node_modules/gatsby-cli
  npm ERR! command failed
  npm ERR! command sh -c node scripts/postinstall.js
  npm ERR! sh: node: command not found
  </code></pre>
  <p>It seems like gatsby-cli trying to run <code>postinstall.js</code> script with <code>node</code> in <code>sh</code> shell, but it is not available there because my nvm/node declared in <code>.zshrc</code>.</p>
  <p>I was able to run nvm and node in <code>sh</code> by creating a <code>.profile</code> file like:</p>
  <pre><code>export NVM_DIR=&quot;~/.nvm&quot;
  [ -s &quot;$NVM_DIR/nvm.sh&quot; ] &amp;&amp; . &quot;$NVM_DIR/nvm.sh&quot; # This loads nvm
  source ~/.nvm/nvm.sh
  
  export PATH=/usr/local/bin:$PATH
  </code></pre>
  <p>But I need to run <code>source ~/.profile</code> for each <code>sh</code> session, otherwise, it doesn't work. As post-install generates a new <code>sh</code> session I can't force it to use <code>.profile</code>.</p>
  <p>I'm not strong in all this shell stuff, so any help appreciated.</p>
  <p>(Note: I have no such problems with installing other npm packages e.g. webpack-cli)</p>