title: Deploying to Firestore Cloud Functions - "Error: cannot find module"
body: <p>I'm getting this when trying to deploy functions:</p>
  <pre><code>Deployment error.
  Build failed: npm ERR! code ENOLOCAL
  npm ERR! Could not install from &quot;../config/myconfig&quot; as it does not contain a package.json file.
  </code></pre>
  <p>This is after even updating the <code>package.json</code> in my <code>functions</code> directory <a href="https://firebase.google.com/docs/functions/handle-dependencies" rel="nofollow noreferrer">as suggested by the official docs</a> to look like this:</p>
  <pre><code>...
  &quot;dependencies&quot;: {
      &quot;sms_sender&quot;: &quot;file:./&quot;,
      &quot;myconfig&quot;: &quot;file:../config/myconfig&quot;,
      &quot;firebase-admin&quot;: &quot;^8.10.0&quot;,
      &quot;firebase-functions&quot;: &quot;^3.6.1&quot;
    },
  ...
  </code></pre>
  <p>which is supposed to fix this error as seen in the stacktrace on the GCP logs:</p>
  <pre><code>A 2020-08-27T12:43:39.026Z sendMessage Could not load the function, shutting down. sendMessage
  A 2020-08-27T12:43:39.020Z sendMessage     at Function.Module._load (internal/modules/cjs/loader.js:585:3) sendMessage
  A 2020-08-27T12:43:39.020Z sendMessage     at tryModuleLoad (internal/modules/cjs/loader.js:593:12) sendMessage
  A 2020-08-27T12:43:39.020Z sendMessage     at Module.load (internal/modules/cjs/loader.js:653:32) sendMessage
  A 2020-08-27T12:43:39.020Z sendMessage     at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10) sendMessage
  A 2020-08-27T12:43:39.019Z sendMessage     at Module._compile (internal/modules/cjs/loader.js:778:30) sendMessage
  A 2020-08-27T12:43:39.019Z sendMessage     at Object.&lt;anonymous&gt; (/workspace/sms_sender.js:5:16) sendMessage
  A 2020-08-27T12:43:39.019Z sendMessage     at require (internal/modules/cjs/helpers.js:25:18) sendMessage
  A 2020-08-27T12:43:39.019Z sendMessage     at Module.require (internal/modules/cjs/loader.js:692:17) sendMessage
  A 2020-08-27T12:43:39.019Z sendMessage     at Function.Module._load (internal/modules/cjs/loader.js:562:25) sendMessage
  A 2020-08-27T12:43:39.019Z sendMessage     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15) sendMessage
  A 2020-08-27T12:43:39.019Z sendMessage Detailed stack trace: Error: Cannot find module '../config/myconfig' sendMessage
  A 2020-08-27T12:43:39.019Z sendMessage Did you list all required modules in the package.json dependencies? sendMessage
  A 2020-08-27T12:43:39.019Z sendMessage Provided module can't be loaded. sendMessage
  </code></pre>
  <p>sendMessage is my background function in index.js which imports the 'sms_sender' module:</p>
  <pre><code>exports.sendMessage = functions.https.onRequest(async (req, res) =&gt; {
    ...
    // send the sendMessage
    sms_sender.sendMsg(&quot;+123567890&quot;, &quot;hello, my friend!&quot;);
    ...
  }
  </code></pre>
  <p>sms_sender.js:</p>
  <pre><code>const config = require('../config/myconfig');
  
  module.exports = {
    sendMsg: async function(recipientNum, message) {
      ...
    }
  }
  </code></pre>
  <p>project structure:</p>
  <pre><code>/project-root
      /config
          myconfig.js
      /functions
          index.js
          sms_sender.js
          package.json
      /tests
      ...
      package.json
  </code></pre>
  <p>I looked at this <a href="https://stackoverflow.com/a/49461423/1145905">related post</a> but it was talking about an external dependency.</p>
  <p>How should I tell Node/npm that 'myconfig' is just a local file and not really a module per se?
  I tried putting in a stub 'package.json' file to /config but I still get the same <code>Could not install from &quot;../config/myconfig&quot; as it does not contain a package.json file.</code> error</p>