问题
I am getting the following error when executing the command firebase deploy --only function in my Ionic 3 project. This solution is not working for me.
Running command: npm --prefix "$RESOURCE_DIR" run build
> functions@ build /Users/myuser/Project/functions
> tsc
node_modules/firebase-functions/lib/function-configuration.d.ts:4:64 - error TS1005: ']' expected.
4 export declare const SUPPORTED_REGIONS: readonly ["us-central1", "us-east1", "us-east4", "europe-west1", "europe-west2", "asia-east2", "asia-northeast1"];
~
node_modules/firebase-functions/lib/function-configuration.d.ts:4:66 - error TS1134: Variable declaration expected.
4 export declare const SUPPORTED_REGIONS: readonly ["us-central1", "us-east1", "us-east4", "europe-west1", "europe-west2", "asia-east2", "asia-northeast1"];
~~~~~~~~~~
node_modules/firebase-functions/lib/function-configuration.d.ts:4:153 - error TS1005: ';' expected.
4 export declare const SUPPORTED_REGIONS: readonly ["us-central1", "us-east1", "us-east4", "europe-west1", "europe-west2", "asia-east2", "asia-northeast1"];
~
node_modules/firebase-functions/lib/function-configuration.d.ts:16:61 - error TS1005: ']' expected.
16 export declare const VALID_MEMORY_OPTIONS: readonly ["128MB", "256MB", "512MB", "1GB", "2GB"];
~
node_modules/firebase-functions/lib/function-configuration.d.ts:16:63 - error TS1134: Variable declaration expected.
16 export declare const VALID_MEMORY_OPTIONS: readonly ["128MB", "256MB", "512MB", "1GB", "2GB"];
~~~~~~~
node_modules/firebase-functions/lib/function-configuration.d.ts:16:93 - error TS1005: ';' expected.
16 export declare const VALID_MEMORY_OPTIONS: readonly ["128MB", "256MB", "512MB", "1GB", "2GB"];
~
When I look into file node_modules/firebase-functions/lib/function-configuration.d.ts, it shows the syntax errors.
Version details:
"angularfire2": "^5.2.1",
"firebase": "^6.3.1",
"firebase-admin": "^8.2.0",
"firebase-functions": "3.2.0",
"typescript": "^3.5.3"
回答1:
npm install -g typescript@3.5.3 worked for me. I assume higher versions would work as well. It is important to update the global typescript version as my local typescript version update didn't work
回答2:
Judging from the github issue that you linked and the error message itself, the error seems to be due to the new readonly tuples feature. It was introduced in typescript@3.4.0 so, in theory, any typescript version higher than that should work.
In fact, firebase-functions@3.2.0 uses typescript@3.5.2 so I recommend you use the same or higher.
That being said, I see that you have already used typescript@3.5.3 but the error still popped up.
Version details:
"angularfire2": "^5.2.1", "firebase": "^6.3.1", "firebase-admin": "^8.2.0", "firebase-functions": "3.2.0", "typescript": "^3.5.3"
It may be because of a different (older) typescript version being used by some other package internally. Please check your package-lock.json (or yarn.lock) to confirm.
If that's not the case, then my next best guess is that ionic-app-scripts is using older typescript internally.
回答3:
In my case I just removed stub type from my packege.json and it started working for me updating just everything was not working, because this old shit is not compatable with the newer version of firebase well you didnt mentioned in your question that you do have this in your dependencies but I am 100% sure the problem is coming from here, because I just spent a whole night because of this:
"dependencies": {
"@types/firebase": "^3.2.1", <<====== this is shit man
"@types/fs-extra": "^8.0.1",
"@types/mongoose": "^5.5.43",
"@types/request": "^2.48.4",
"actions-on-google": "^2.12.0",
"bcrypt-inzi": "^1.0.7",
"body-parser": "^1.18.3",
"dialogflow-fulfillment": "^0.6.1",
"express": "^4.17.1",
"firebase-admin": "^8.6.0",
"firebase-functions": "^3.3.0",
"fs-extra": "^8.1.0",
"mongoose": "^5.8.9",
"request": "^2.88.0"
},
have you noticed this warning when running npm i
npm WARN deprecated @types/firebase@3.2.1: This is a stub types definition for Firebase API (https://www.firebase.com/docs/javascript/firebase). Firebase API provides its own type definitions, so you don't need @types/firebase installed!
since firebase functions have its own typing file it is not required at all now
来源:https://stackoverflow.com/questions/57242813/node-modules-firebase-functions-lib-function-configuration-d-ts464-error-ts1