question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Function emulators throwing incorrect error message "Cannot find module './tsconfig.json' './tsconfig.json' error "

See original GitHub issue

[REQUIRED] Environment info

firebase-tools: 8.4.2

Platform: Windows 10

[REQUIRED] Test case

I have a set of working and currently deployed functions I am trying to emulate. They are written in JavaScript and the project is not configured for TypeScript.

When I try to emulate my functions I am receiving the following error

!  functions: Cannot find module './tsconfig.json'
!  Your function was killed because it raised an unhandled error.

Trying to find the problem I init a clean project and wrote the following

index.js

const functions = require('firebase-functions');
const { text } = require('./utils/helpers')

exports.helloWorld = functions.https.onRequest((request, response) => {
  let responseText = text()
  response.send(responseText);
});

utils/helpers.js

exports.text = () => {
  return 'hello world'
}

Which worked.

However if I changed the require for helpers to …utils/helpers (which does not exist) I received the error:

!  functions: Cannot find module './tsconfig.json'
!  Your function was killed because it raised an unhandled error.

I can only assume there is something in my code emulators does not like however this is the only error message I am getting so I cannot find it. If I remove all code from my index file (in my actual project) and write a simple function the emulators will run.

[REQUIRED] Steps to reproduce

Changed the require for helpers to …utils/helpers (which does not exist) in index.js

[REQUIRED] Expected behavior

Receive meaningful error message

[REQUIRED] Actual behavior

Receive C:\Github\test-emulators\firebase-debug.log

!  functions: Cannot find module './tsconfig.json'
!  Your function was killed because it raised an unhandled error.

Project is not written in or configured for TypeScript

firebase-debug.log firebase-debug.log

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:6
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

23reactions
SOHELAHMED7commented, Jun 15, 2020

I just tried with master branch, and I got success. The emulator works fine. The issue is fixed. In case you want to try:

  • uninstall already installed firebase tools $ npm uninstall -g firebase-tools
  • install firebase tools with master branch $ npm install -g git://github.com/firebase/firebase-tools.git#master --save
  • run emulator /path/to/project/functions $ firebase emulators:start --only=functions

@samtstern I would like to know if there is any date time is set when the next version will be released, if yes please share.

Thanks very much.

3reactions
julioflimacommented, Jun 15, 2020

Same problem here.

Googling the problem i found this solution: https://medium.com/@onwuka_gideon/functions-cannot-find-module-tsconfig-json-how-i-fixed-it-70d7c4769174

Answer downgrade to 6.3.1 the firebase-tools, but seems to me much oldest, and unproductive without restart after some changes. But send to me a perfect description was happen to cause the error, I was using admin.initializeApp() twice at my code.

So, what is happening with meaningful erros?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fixing The "Cannot Find Module" Error In TypeScript
In this article, I explain how to fix "cannot find module" in TypeScript. Install the package. Re-install the dependencies.
Read more >
firebase function Error: Cannot find module when serving ...
Found the issue in my tsconfig.json. Firebase will look in the package.json's main property to find your function code, in my case I...
Read more >
TypeScript error in Visual Studio – Cannot find module ...
To fix your error messages, first, remove the tsconfig.json file from your project. This then makes the Typescript build on the properties page ......
Read more >
Understanding TypeScript's “Compilation Process” & the ...
When you run tsc command in a directory, TypeScript compiler looks for the tsconfig.json file in the current directory and if it doesn't...
Read more >
API - esbuild
json files is interpreted to prefer browser-specific code. If no custom conditions are configured, the Webpack-specific module condition is also included. The ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found