1

When I attempt to firebase deploy I get the following error.

It seems to be about this line: import * as functions from 'firebase-functions'; at the begining of my file. I have not had any issues with this in the past. But I have recently been having issues with NPM and deploying.

Error: Error occurred while parsing your function triggers.

/Users/name/Desktop/Yoveo/functions/src/index.ts:1
import * as functions from 'firebase-functions';
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at wrapSafe (internal/modules/cjs/loader.js:1052:16)
    at Module._compile (internal/modules/cjs/loader.js:1100:27)
    at Module._compile (pkg/prelude/bootstrap.js:1281:32)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1156:10)
    at Module.load (internal/modules/cjs/loader.js:984:32)
    at Function.Module._load (internal/modules/cjs/loader.js:877:14)
    at Module.require (internal/modules/cjs/loader.js:1024:19)
    at Module.require (pkg/prelude/bootstrap.js:1225:31)
    at require (internal/modules/cjs/helpers.js:72:18)
    at /Users/name/.cache/firebase/tools/lib/node_modules/firebase-tools/lib/triggerParser.js:15:15

Having trouble? Try firebase [command] --help
name@name-MacBook-Pro functions % 

How can I fix it?

I ran npm update and then ran firebase deploy again. got the same error. But with a recommendation to run npm install -g firebase-tools which after running deploy again, resulted in no change for the error.

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
NCT 127
  • 596
  • 1
  • 6
  • 27
  • Please edit the question to show what you did to get to this point. There should be enough information in the question so that anyone can reproduce the issue. – Doug Stevenson Nov 17 '20 at 23:40
  • @DougStevenson I've had this issue for months. I don't think I will be able to recreate it. I will see what I can do. – NCT 127 Nov 17 '20 at 23:41
  • I was unable to recreate. If anyone has suggestions that would be helpful. – NCT 127 Nov 18 '20 at 01:55
  • We need at least a part of your code. Also check the similar questions https://stackoverflow.com/questions/59761839/syntaxerror-cannot-use-import-statement-outside-a-module-firebase-functions, https://stackoverflow.com/questions/60871924/what-is-the-correct-way-to-split-firebase-cloud-functions-into-different-files – Jaroslav Nov 18 '20 at 16:31

1 Answers1

1

Solved: I searched AsyncIterable in my folder. It returned a bunch of associated files connected to the different projects I have. I then highlighted and looked at the file path for all of them.

I found that the ones working correctly where associated with a project, and that the project that was not working would not show up. Except, however, for some files associated with no Xcode project.

Thus I concluded that there may have been a problem with the initial setup where many necessary files were associated with no particular project. Dont know how that happened. I will work to solve that now. Comment if you know how I could redo this or fix this issue.

NCT 127
  • 596
  • 1
  • 6
  • 27