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:
- Created 3 years ago
- Reactions:6
- Comments:7 (4 by maintainers)
I just tried with master branch, and I got success. The emulator works fine. The issue is fixed. In case you want to try:
$ npm uninstall -g firebase-tools
$ npm install -g git://github.com/firebase/firebase-tools.git#master --save
/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.
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?