title: Setting env variable in package.json
body: <p>I have a single environment variable that I need to set during <code>preinstall</code> (my npm token is needed in <code>.npmrc</code> to fetch a private package). This particular env var is stored within a config service I am using (Firebase) and so it needs to be fetched from the service and then added to the env. </p>
  
  <p>I've tried all manner of ways, such as fetching it in a node script and trying to capture it via stdout:</p>
  
  <pre><code>const { spawnSync } = require( 'child_process' );
  const ls = spawnSync( 'firebase', [ 'functions:config:get', 'npm.read_only' ] );
  
  JSON.parse(ls.stdout.toString());
  // Printing this shows the correct token
  </code></pre>
  
  <p>My latest try was this:</p>
  
  <pre><code>#!/bin/sh
  
  echo 'Setting up development env';
  
  NPM_READ_ONLY_TOKEN=`firebase functions:config:get npm.read_only`
  
  export NPM_READ_ONLY_TOKEN=$(eval echo $NPM_READ_ONLY_TOKEN)
  
  echo 'NPM_READ_ONLY_TOKEN =&gt; '$NPM_READ_ONLY_TOKEN;
  # Prints the correct token on the screen
  
  exit 0;
  </code></pre>
  
  <p>But, when running <code>"./configEnv.sh &amp;&amp; echo $NPM_READ_ONLY_TOKEN"</code>, the env var is empty.</p>
  
  <p>How can I achieve this? </p>