New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Functions only deploy erroring, referencing parent application node_modules folder #749
Comments
If you ran |
It does not. Same error. |
Then it's something to do with your TypeScript set up or how you import modules inside your code. It's not a bug with firebase-tools. |
@laurenzlong Ok, thanks for taking the time to help me out on this one. I guess I'm wondering why the firebase cloud functions even cares about which packages I include in my application. I've created a |
"npm run build" uses regular "tsc" to build your files. This has nothing to do with Firebase or Cloud Functions. |
@laurenzlong Thanks again! That helped me track down what I needed to do to solve my issue. To anyone else running into this issue - I was able to get the functions to build successfully by modifying the functions build script to use |
@dylanjmcdonald or put it in the tsconfig.json file: // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
"skipLibCheck": true,
/* Strict Type-Checking Options */
"strict": true, Thanks for the heads up, btw 👍 |
But what if you don't want to skip checking the declaration? In one of my cloud functions I use Objects.entries() which is es2017. I set it in tsconfig.json but because it's skipping it it throws an error when the function is executed. Any other way around this? |
I fixed the same problem by adding: |
This happens with the stock autogenerated typescript when functions are initialized for me. Just the autogenerated code and imports that are exactly like they are in the examples. It seems to be because tsc will look for types up your process tree and tries to typecheck everything in the @types files but nothing else so things go to shit? I think the most correct solution to this is to do as Gongevangen suggested. add "node_modules/@types" to typeRoots so that the module resolution algorithm doesn't go nuts up the tree. |
I got the same issus thanks to @dylanjmcdonald I have solved it by using tsc --skipLibCheck |
@dylanjmcdonald |
I fixed by adding {
"compilerOptions": {
"lib": ["es6", "dom"],
"module": "commonjs",
"noImplicitReturns": true,
"outDir": "lib",
"sourceMap": true,
"target": "es6"
},
"compileOnSave": true,
"include": [
"src"
]
} |
This should work also. I used @yamitzky solution and worked for a function deploy. The below is usable as per a google dev's code I viewed. |
It's great that there are work-arounds for this this, but one of these solutions should really be in the |
You could re-open this issue, but I can tell you that we probably won't be adding |
Thanks sir |
Make sure that your .ts file is same name as .js in lib and also include it in package.json |
Just to clarify @gongevangen 's solution works but make sure to place the
Kinda confused as to why this wouldn't be included in the boilerplate...or even mentioned anywhere in any of the Firebase tuts. |
I agree with @evanb2 - this just cost me an hour! Surely it would be worth at least mentioning it here: https://firebase.google.com/docs/functions/typescript if not including it in firebase init? |
God bless you Evanb2! :) |
I was able to fix it by updating the typescript version in de package.json. If I was running 'tsc' in the terminal it was woking, but if I was running "npm run build" (that actually does tsc too), it was working. Try run tsc -v, then put the same version in the package.json then npm i. |
Can confirm this is the only solution that worked for me! Thanks a bunch. |
Thank you so much |
Version info
firebase: 3.18.4
node: 8.10.0
npm: 5.6.0
Platform Information
Windows
Steps to reproduce
firebase deploy --only functions
Expected behavior
Firebase cloud functions will deploy successfully.
Actual behavior
Receiving an error because the cloud functions build seems to be referencing the node_modules folder from the root level of the application.
@types/d3
and@types/googlemaps
are included in my applications package.json file and not my functions package.json file.The text was updated successfully, but these errors were encountered: