0
votes

Ok so I am ripping my hair out for this...

For some reason even though I have followed all of the necessary instructions for firebase cloud functions I can't deploy I get the error message:

Build failed: Specified version range of module @firebase/app is not a string

But I can't see where this specified version range should not be a string? I have looked in the package.json but can't see where it should be wrong:

    "@firebase/app": {
          "version": "0.1.6",
          "resolved": "https://registry.npmjs.org/@firebase/app/-/app-0.1.6.tgz",
          "integrity": "sha512-zvA+Tsc6lmuMYmDYsgoXpmPzzLLhdeH97/UVN79YGlFqCihrYAaKUi1/osoAhjXPZaV1+TXoqiSEB2vWHU7Puw==",
          "requires": {
            "@firebase/app-types": "0.1.1",
            "@firebase/util": "0.1.6"
          }
}

I am also guessing that it is only because this is the first module that this error shows up, something seems fundamentally wrong.

I had to install npm modules through sudo, could this be the problem? it created a locked package-locked.json file which I renamed "package.json" to just be able to deploy at all.

Thanks in advance!

2
Is that from your package.json? If so, that's your problem. Dependencies need to be declared like: {"dependencies": {"@firebase/app": "^0.1.6"}} not as a nested object as you pasted. - Michael Bleigh
@MichaelBleigh thanks for the answer! That is indeed from the package.json, but I just installed it using "sudo npm install firebase-admin --save" so that is why I am confused. Do you mean I should rewrite this manually? - Martin Kjellberg
I noticed now that you're absolutely right about the package.json file, I compared it to another one from previous projects. Will try to copy that one in and see if I get any progress - Martin Kjellberg

2 Answers

2
votes

I ran into the same problem. My issue was that the "engines" section was in the dependency section. Fixed as follows:

{
  "name": "functions",
  "description": "Cloud Functions for Firebase",
  "scripts": {
    "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": {
    "actions-on-google": "2.0.0-alpha.4",
    "async": "^2.6.1",
    "dialogflow": "^0.1.0",
    "dialogflow-fulfillment": "0.3.0-beta.3",
    "firebase-admin": "^6.0.0",
    "firebase-functions": "^2.1.0",
    "firebase-tools": "6.0.1",
    "geofirex": "^0.0.6",
    "google-auth-library": "1.6.1",
    "googleapis": "32.0.0",
    "lodash.get": "^4.4.2",
    "request": "^2.87.0",
    "rss-parser": "^3.5.2",
    "rxjs": "^6.3.3"
  },
  "private": true
}
0
votes

Sorry for the problems.

I figured out the solution, apparently my npm init didn't work. I re did it and all commands worked as they should.

Solution for this error:

  1. Delete package.json & node_modules

  2. Run "npm init"

  3. Reinstall node modules

Now you should be able to deploy as usual.

Thanks to @MichaelBleigh for helping me realize this dumb error