title: Getting "Error: Cannot find module 'request'" even though I have added request module
body: <p>I am trying to use <code>request</code> for my Cloud Function.</p>
  
  <p>I have installed <code>request</code> package via <code>npm install request</code>. It sits in <code>node_modules</code> like every other package:</p>
  
  <p><a href="https://i.stack.imgur.com/RaBSu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RaBSu.png" alt="enter image description here"></a></p>
  
  <p>However when I try to upload my Cloud Function, I get the following error message:</p>
  
  <pre><code>Function failed on loading user code. Error message: Code in file index.js can't be loaded.
  Did you list all required modules in the package.json dependencies?
  Detailed stack trace: Error: Cannot find module 'request'
      at Function.Module._resolveFilename (module.js:548:15)
      at Function.Module._load (module.js:475:25)
      at Module.require (module.js:597:17)
      at require (internal/module.js:11:18)
      at Object.&lt;anonymous&gt; (/srv/index.js:3:17)
      at Module._compile (module.js:653:30)
      at Object.Module._extensions..js (module.js:664:10)
      at Module.load (module.js:566:32)
      at tryModuleLoad (module.js:506:12)
      at Function.Module._load (module.js:498:3)
  </code></pre>
  
  <p>Here's my <code>index.js</code>:</p>
  
  <pre><code>const functions = require('firebase-functions');
  const admin = require('firebase-admin');
  const request = require('request');
  
  admin.initializeApp();
  const db = admin.firestore();
  
  function getFoursquarePlace(midPoint){
      let url = "https://api.foursquare.com/v2/venues/search?" +
      "ll=" + midPoint.latitude + "," + midPoint.longitude + "&amp;client_id=" +
      client_id + "&amp;client_secret=" + client_secret + "&amp;v=" + version + "&amp;radius=" + radius 
      + "&amp;limit=" + limit + "&amp;categoryId=" + categorySet;
  
      request(url, options, (error, res, body) =&gt; {
      if (error) {
          return console.log(error)
      }
  
      if (!error &amp;&amp; res.statusCode === 200) {
          // do something with JSON, using the 'body' variable
              console.log("body: " + res.body);
          }
      });
  </code></pre>
  
  <p>Does anyone know what the problem may be? I've tried uninstalling and reinstalling <code>request</code> but still getting the error.</p>
  
  <p>Edit: I've checked <code>package-lock.json</code> and the <code>request</code> package is in there:</p>
  
  <pre><code>"request": {
    "version": "2.88.0",
    "resolved": "https://registry.npmjs.org/request/-/request-2.88.0.tgz",
    "integrity": "sha512-NAqB3rk3LgxdsfHnTBNwN0E+lHDAJzu7m0328eY08z2/A0hg==",
    "requires": {
      "aws-sign2": "~0.7.0",
      "aws4": "^1.8.0",
      "caseless": "~0.12.0",
      "combined-stream": "~1.0.6",
      "extend": "~3.0.2",
      "forever-agent": "~0.6.1",
      "form-data": "~2.3.2",
      "har-validator": "~5.1.0",
      "http-signature": "~1.2.0",
      "is-typedarray": "~1.0.0",
      "isstream": "~0.1.2",
      "json-stringify-safe": "~5.0.1",
      "mime-types": "~2.1.19",
      "oauth-sign": "~0.9.0",
      "performance-now": "^2.1.0",
      "qs": "~6.5.2",
      "safe-buffer": "^5.1.2",
      "tough-cookie": "~2.4.3",
      "tunnel-agent": "^0.6.0",
      "uuid": "^3.3.2"
    }
  },
  </code></pre>
  
  <p>package.json</p>
  
  <pre><code>{
    "name": "functions",
    "description": "Cloud Functions for Firebase",
    "scripts": {
      "lint": "eslint .",
      "serve": "firebase serve --only functions",
      "shell": "firebase functions:shell",
      "start": "npm run shell",
      "deploy": "firebase deploy --only functions",
      "logs": "firebase functions:log"
    },
    "engines": {
      "node": "8"
    },
    "dependencies": {
      "firebase-admin": "^8.0.0",
      "firebase-functions": "^3.1.0",
      "geofirestore": "3.3.1"
    },
    "devDependencies": {
      "eslint": "^5.12.0",
      "eslint-plugin-promise": "^4.0.1",
      "firebase-functions-test": "^0.1.6"
    },
    "private": true
  }
  </code></pre>