title: firebase show error when i try to run functions locally
body: <p>Showing the Firebase error whenever I run the function locally using emulator in CLI</p>
  
  <pre><code>$ firebase emulators:start --only functions
  </code></pre>
  
  <blockquote>
    <p>Starting emulators: ["functions"]</p>
    
    <p>functions: Using node@8 from host.</p>
    
    <p>functions: Emulator started at <a href="http://localhost:5001" rel="nofollow noreferrer">http://localhost:5001</a></p>
    
    <p>functions: Watching "E:\dir\functions" for Cloud Functions...</p>
    
    <p>Error: Cannot find module 'E:\dir\functions'</p>
    
    <p>at Function.Module._resolveFilename (module.js:548:15)</p>
    
    <p>at Function.Module._load (module.js:475:25)</p>
    
    <p>at Module.require (module.js:597:17)</p>
    
    <p>at require (internal/module.js:11:18)</p>
    
    <p>at C:\Users\d\AppData\Roaming\npm\node_modules\firebase-tools\lib\emulator\functionsEmulatorRuntime.js:459:29</p>
    
    <p>at Generator.next ()</p>
    
    <p>at C:\Users\d\AppData\Roaming\npm\node_modules\firebase-tools\lib\emulator\functionsEmulatorRuntime.js:7:71</p>
    
    <p>at new Promise ()</p>
    
    <p>at __awaiter (C:\Users\d\AppData\Roaming\npm\node_modules\firebase-tools\lib\emulator\functionsEmulatorRuntime.js:3:12)</p>
    
    <p>at main (C:\Users\d\AppData\Roaming\npm\node_modules\firebase-tools\lib\emulator\functionsEmulatorRuntime.js:421:12)</p>
    
    <p>Your function was killed because it raised an unhandled error.</p>
  </blockquote>
  
  <p>I use <strong>typescript</strong> to write cloud functions.</p>
  
  <p>here is my <strong>index.ts</strong></p>
  
  <pre><code>import * as functions from 'firebase-functions';
  import * as admin from "firebase-admin";
  
  var cert = require("./skey.json");
  
  admin.initializeApp({
      credential: admin.credential.cert(cert),
      databaseURL: "https://bhau-tk.firebaseio.com"
  });
  
  exports.basicHTTP = functions.https.onRequest((req, res) =&gt; {
      res.send("Hello world!!");
  })
  </code></pre>
  
  <p><strong>package.json</strong> contains</p>
  
  <pre><code>{
    "name": "functions",
    "scripts": {
      "lint": "tslint --project tsconfig.json",
      "build": "tsc",
      "serve": "npm run build &amp;&amp; firebase serve --only functions",
      "shell": "npm run build &amp;&amp; firebase functions:shell",
      "start": "npm run shell",
      "deploy": "firebase deploy --only functions",
      "logs": "firebase functions:log"
    },
    "engines": {
      "node": "8"
    },
    "main": "lib/index.js",
    "dependencies": {
      "firebase-admin": "~7.0.0",
      "firebase-functions": "^2.3.0",
      "firebase-functions-test": "^0.1.6"
    },
    "devDependencies": {
      "tslint": "^5.12.0",
      "typescript": "^3.2.2"
    },
    "private": true
  }
  </code></pre>
  
  <p>and <strong>project structure</strong> is</p>
  
  <p><a href="https://i.stack.imgur.com/tPgb6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tPgb6.png" alt="enter image description here"></a></p>