firebase-tools: Functions only deploy erroring, referencing parent application node_modules folder
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.
=== Deploying to 'PROJECT_NAME'...
i deploying functions
Running command: npm --prefix "$RESOURCE_DIR" run lint
> functions@ lint [PATH ON LOCAL MACHINE]\functions
> tslint --project tsconfig.json
Running command: npm --prefix "$RESOURCE_DIR" run build
> functions@ build [PATH ON LOCAL MACHINE]\functions
> tsc
../node_modules/@types/d3-axis/index.d.ts(50,36): error TS2304: Cannot find name 'SVGSVGElement'.
../node_modules/@types/d3-axis/index.d.ts(50,52): error TS2304: Cannot find name 'SVGGElement'.
../node_modules/@types/d3-brush/index.d.ts(32,23): error TS2304: Cannot find name 'SVGGElement'.
../node_modules/@types/d3-brush/index.d.ts(39,27): error TS2304: Cannot find name 'SVGGElement'.
../node_modules/@types/d3-brush/index.d.ts(50,27): error TS2304: Cannot find name 'SVGGElement'.
../node_modules/@types/d3-brush/index.d.ts(63,27): error TS2304: Cannot find name 'SVGGElement'.
../node_modules/@types/d3-brush/index.d.ts(63,77): error TS2304: Cannot find name 'SVGGElement'.
../node_modules/@types/d3-brush/index.d.ts(70,27): error TS2304: Cannot find name 'SVGGElement'.
../node_modules/@types/d3-brush/index.d.ts(81,32): error TS2304: Cannot find name 'SVGGElement'.
../node_modules/@types/d3-brush/index.d.ts(94,32): error TS2304: Cannot find name 'SVGGElement'.
../node_modules/@types/d3-brush/index.d.ts(94,72): error TS2304: Cannot find name 'SVGGElement'.
../node_modules/@types/d3-brush/index.d.ts(98,23): error TS2304: Cannot find name 'SVGGElement'.
../node_modules/@types/d3-brush/index.d.ts(121,28): error TS2304: Cannot find name 'SVGGElement'.
../node_modules/@types/d3-brush/index.d.ts(126,23): error TS2304: Cannot find name 'SVGGElement'.
../node_modules/@types/d3-brush/index.d.ts(138,30): error TS2304: Cannot find name 'SVGGElement'.
../node_modules/@types/d3-brush/index.d.ts(164,36): error TS2304: Cannot find name 'SVGGElement'.
../node_modules/@types/d3-brush/index.d.ts(191,45): error TS2304: Cannot find name 'SVGGElement'.
../node_modules/@types/d3-brush/index.d.ts(223,38): error TS2304: Cannot find name 'SVGGElement'.
../node_modules/@types/d3-chord/index.d.ts(360,16): error TS2304: Cannot find name 'CanvasRenderingContext2D'.
../node_modules/@types/d3-chord/index.d.ts(368,22): error TS2304: Cannot find name 'CanvasRenderingContext2D'.
../node_modules/@types/d3-dispatch/index.d.ts(8,37): error TS2304: Cannot find name 'EventTarget'.
../node_modules/@types/d3-dispatch/index.d.ts(18,36): error TS2304: Cannot find name 'EventTarget'.
../node_modules/@types/d3-drag/index.d.ts(19,38): error TS2304: Cannot find name 'Element'.
../node_modules/@types/d3-drag/index.d.ts(24,36): error TS2304: Cannot find name 'HTMLElement'.
../node_modules/@types/d3-drag/index.d.ts(24,50): error TS2304: Cannot find name 'SVGSVGElement'.
../node_modules/@types/d3-drag/index.d.ts(24,66): error TS2304: Cannot find name 'SVGGElement'.
../node_modules/@types/d3-drag/index.d.ts(390,37): error TS2304: Cannot find name 'Window'.
../node_modules/@types/d3-drag/index.d.ts(402,36): error TS2304: Cannot find name 'Window'.
../node_modules/@types/d3-fetch/index.d.ts(18,42): error TS2304: Cannot find name 'RequestInit'.
../node_modules/@types/d3-fetch/index.d.ts(18,64): error TS2304: Cannot find name 'Blob'.
../node_modules/@types/d3-fetch/index.d.ts(27,44): error TS2304: Cannot find name 'RequestInit'.
../node_modules/@types/d3-fetch/index.d.ts(41,12): error TS2304: Cannot find name 'RequestInit'.
../node_modules/@types/d3-fetch/index.d.ts(82,11): error TS2304: Cannot find name 'RequestInit'.
../node_modules/@types/d3-fetch/index.d.ts(100,12): error TS2304: Cannot find name 'RequestInit'.
../node_modules/@types/d3-fetch/index.d.ts(145,11): error TS2304: Cannot find name 'RequestInit'.
../node_modules/@types/d3-fetch/index.d.ts(157,42): error TS2304: Cannot find name 'RequestInit'.
../node_modules/@types/d3-fetch/index.d.ts(157,64): error TS2304: Cannot find name 'Document'.
../node_modules/@types/d3-fetch/index.d.ts(167,74): error TS2304: Cannot find name 'HTMLImageElement'.
../node_modules/@types/d3-fetch/index.d.ts(179,72): error TS2304: Cannot find name 'RequestInit'.
../node_modules/@types/d3-fetch/index.d.ts(189,41): error TS2304: Cannot find name 'RequestInit'.
../node_modules/@types/d3-fetch/index.d.ts(189,63): error TS2304: Cannot find name 'Document'.
../node_modules/@types/d3-fetch/index.d.ts(199,42): error TS2304: Cannot find name 'RequestInit'.
../node_modules/@types/d3-fetch/index.d.ts(212,12): error TS2304: Cannot find name 'RequestInit'.
../node_modules/@types/d3-fetch/index.d.ts(254,11): error TS2304: Cannot find name 'RequestInit'.
../node_modules/@types/d3-fetch/index.d.ts(266,41): error TS2304: Cannot find name 'RequestInit'.
../node_modules/@types/d3-fetch/index.d.ts(266,63): error TS2304: Cannot find name 'XMLDocument'.
../node_modules/@types/d3-selection/index.d.ts(17,24): error TS2304: Cannot find name 'Element'.
../node_modules/@types/d3-selection/index.d.ts(17,49): error TS2304: Cannot find name 'Document'.
../node_modules/@types/d3-selection/index.d.ts(17,60): error TS2304: Cannot find name 'Window'.
../node_modules/@types/d3-selection/index.d.ts(34,20): error TS2304: Cannot find name 'Document'.
../node_modules/@types/d3-selection/index.d.ts(36,27): error TS2304: Cannot find name 'Node'.
../node_modules/@types/d3-selection/index.d.ts(36,34): error TS2304: Cannot find name 'Node'.
../node_modules/@types/d3-selection/index.d.ts(37,28): error TS2304: Cannot find name 'Node'.
../node_modules/@types/d3-selection/index.d.ts(37,44): error TS2304: Cannot find name 'Node'.
../node_modules/@types/d3-selection/index.d.ts(37,51): error TS2304: Cannot find name 'Node'.
../node_modules/@types/d3-selection/index.d.ts(38,39): error TS2304: Cannot find name 'Element'.
../node_modules/@types/d3-selection/index.d.ts(39,42): error TS2304: Cannot find name 'NodeListOf'.
../node_modules/@types/d3-selection/index.d.ts(39,53): error TS2304: Cannot find name 'Element'.
../node_modules/@types/d3-selection/index.d.ts(45,32): error TS2304: Cannot find name 'HTMLElement'.
../node_modules/@types/d3-selection/index.d.ts(45,46): error TS2304: Cannot find name 'SVGSVGElement'.
../node_modules/@types/d3-selection/index.d.ts(45,62): error TS2304: Cannot find name 'SVGGElement'.
../node_modules/@types/d3-selection/index.d.ts(110,110): error TS2304: Cannot find name 'HTMLElement'.
../node_modules/@types/d3-selection/index.d.ts(142,113): error TS2304: Cannot find name 'HTMLElement'.
../node_modules/@types/d3-selection/index.d.ts(873,43): error TS2304: Cannot find name 'HTMLElement'.
../node_modules/@types/d3-selection/index.d.ts(977,61): error TS2304: Cannot find name 'TouchList'.
../node_modules/@types/d3-selection/index.d.ts(989,64): error TS2304: Cannot find name 'TouchList'.
../node_modules/@types/d3-selection/index.d.ts(1013,29): error TS2304: Cannot find name 'Element'.
../node_modules/@types/d3-selection/index.d.ts(1025,15): error TS2304: Cannot find name 'Element'.
../node_modules/@types/d3-selection/index.d.ts(1033,18): error TS2304: Cannot find name 'Element'.
../node_modules/@types/d3-selection/index.d.ts(1040,15): error TS2304: Cannot find name 'Element'.
../node_modules/@types/d3-selection/index.d.ts(1040,35): error TS2304: Cannot find name 'Element'.
../node_modules/@types/d3-selection/index.d.ts(1108,33): error TS2304: Cannot find name 'Window'.
../node_modules/@types/d3-selection/index.d.ts(1108,42): error TS2304: Cannot find name 'Document'.
../node_modules/@types/d3-selection/index.d.ts(1108,53): error TS2304: Cannot find name 'Element'.
../node_modules/@types/d3-selection/index.d.ts(1108,63): error TS2304: Cannot find name 'Window'.
../node_modules/@types/d3-selection/index.d.ts(1122,44): error TS2304: Cannot find name 'Element'.
../node_modules/@types/d3-selection/index.d.ts(1133,45): error TS2304: Cannot find name 'Element'.
../node_modules/@types/d3-selection/index.d.ts(1154,46): error TS2304: Cannot find name 'Element'.
../node_modules/@types/d3-selection/index.d.ts(1163,49): error TS2304: Cannot find name 'Element'.
../node_modules/@types/d3-selection/index.d.ts(1163,97): error TS2304: Cannot find name 'NodeListOf'.
../node_modules/@types/d3-shape/index.d.ts(304,16): error TS2304: Cannot find name 'CanvasRenderingContext2D'.
../node_modules/@types/d3-shape/index.d.ts(312,22): error TS2304: Cannot find name 'CanvasRenderingContext2D'.
../node_modules/@types/d3-shape/index.d.ts(757,16): error TS2304: Cannot find name 'CanvasRenderingContext2D'.
../node_modules/@types/d3-shape/index.d.ts(765,22): error TS2304: Cannot find name 'CanvasRenderingContext2D'.
../node_modules/@types/d3-shape/index.d.ts(935,16): error TS2304: Cannot find name 'CanvasRenderingContext2D'.
../node_modules/@types/d3-shape/index.d.ts(943,22): error TS2304: Cannot find name 'CanvasRenderingContext2D'.
../node_modules/@types/d3-shape/index.d.ts(1230,16): error TS2304: Cannot find name 'CanvasRenderingContext2D'.
../node_modules/@types/d3-shape/index.d.ts(1238,22): error TS2304: Cannot find name 'CanvasRenderingContext2D'.
../node_modules/@types/d3-shape/index.d.ts(1536,16): error TS2304: Cannot find name 'CanvasRenderingContext2D'.
../node_modules/@types/d3-shape/index.d.ts(1544,22): error TS2304: Cannot find name 'CanvasRenderingContext2D'.
../node_modules/@types/d3-shape/index.d.ts(1650,15): error TS2304: Cannot find name 'CanvasRenderingContext2D'.
../node_modules/@types/d3-shape/index.d.ts(1686,15): error TS2304: Cannot find name 'CanvasRenderingContext2D'.
../node_modules/@types/d3-shape/index.d.ts(2016,16): error TS2304: Cannot find name 'CanvasRenderingContext2D'.
../node_modules/@types/d3-shape/index.d.ts(2024,22): error TS2304: Cannot find name 'CanvasRenderingContext2D'.
../node_modules/@types/d3-shape/index.d.ts(2196,16): error TS2304: Cannot find name 'CanvasRenderingContext2D'.
../node_modules/@types/d3-shape/index.d.ts(2204,22): error TS2304: Cannot find name 'CanvasRenderingContext2D'.
../node_modules/@types/d3-shape/index.d.ts(2273,19): error TS2304: Cannot find name 'CanvasPathMethods'.
../node_modules/@types/d3-shape/index.d.ts(2358,16): error TS2304: Cannot find name 'CanvasRenderingContext2D'.
../node_modules/@types/d3-shape/index.d.ts(2366,22): error TS2304: Cannot find name 'CanvasRenderingContext2D'.
../node_modules/@types/d3-transition/index.d.ts(572,65): error TS2304: Cannot find name 'HTMLElement'.
../node_modules/@types/d3-transition/index.d.ts(583,104): error TS2304: Cannot find name 'HTMLElement'.
../node_modules/@types/d3-zoom/index.d.ts(20,37): error TS2304: Cannot find name 'Element'.
../node_modules/@types/googlemaps/index.d.ts(33,29): error TS2304: Cannot find name 'Element'.
../node_modules/@types/googlemaps/index.d.ts(37,19): error TS2304: Cannot find name 'Element'.
../node_modules/@types/googlemaps/index.d.ts(54,28): error TS2304: Cannot find name 'Node'.
../node_modules/@types/googlemaps/index.d.ts(788,30): error TS2304: Cannot find name 'Element'.
../node_modules/@types/googlemaps/index.d.ts(799,36): error TS2304: Cannot find name 'Node'.
../node_modules/@types/googlemaps/index.d.ts(812,26): error TS2304: Cannot find name 'Node'.
../node_modules/@types/googlemaps/index.d.ts(1136,20): error TS2304: Cannot find name 'Element'.
../node_modules/@types/googlemaps/index.d.ts(1137,22): error TS2304: Cannot find name 'Element'.
../node_modules/@types/googlemaps/index.d.ts(1138,18): error TS2304: Cannot find name 'Element'.
../node_modules/@types/googlemaps/index.d.ts(1139,22): error TS2304: Cannot find name 'Element'.
../node_modules/@types/googlemaps/index.d.ts(1140,23): error TS2304: Cannot find name 'Element'.
../node_modules/@types/googlemaps/index.d.ts(1141,23): error TS2304: Cannot find name 'Element'.
../node_modules/@types/googlemaps/index.d.ts(1142,29): error TS2304: Cannot find name 'Element'.
../node_modules/@types/googlemaps/index.d.ts(1143,24): error TS2304: Cannot find name 'Element'.
../node_modules/@types/googlemaps/index.d.ts(1220,21): error TS2304: Cannot find name 'Element'.
../node_modules/@types/googlemaps/index.d.ts(1225,25): error TS2304: Cannot find name 'Element'.
../node_modules/@types/googlemaps/index.d.ts(1236,17): error TS2304: Cannot find name 'Element'.
../node_modules/@types/googlemaps/index.d.ts(1653,32): error TS2304: Cannot find name 'Node'.
../node_modules/@types/googlemaps/index.d.ts(1668,64): error TS2304: Cannot find name 'Document'.
../node_modules/@types/googlemaps/index.d.ts(1668,75): error TS2304: Cannot find name 'Element'.
../node_modules/@types/googlemaps/index.d.ts(1669,27): error TS2304: Cannot find name 'Element'.
../node_modules/@types/googlemaps/index.d.ts(1692,64): error TS2304: Cannot find name 'Document'.
../node_modules/@types/googlemaps/index.d.ts(1692,75): error TS2304: Cannot find name 'Element'.
../node_modules/@types/googlemaps/index.d.ts(1693,27): error TS2304: Cannot find name 'Element'.
../node_modules/@types/googlemaps/index.d.ts(1709,64): error TS2304: Cannot find name 'Document'.
../node_modules/@types/googlemaps/index.d.ts(1709,75): error TS2304: Cannot find name 'Element'.
../node_modules/@types/googlemaps/index.d.ts(1710,27): error TS2304: Cannot find name 'Element'.
../node_modules/@types/googlemaps/index.d.ts(1941,32): error TS2304: Cannot find name 'Element'.
../node_modules/@types/googlemaps/index.d.ts(1942,28): error TS2304: Cannot find name 'Node'.
../node_modules/@types/googlemaps/index.d.ts(2394,36): error TS2304: Cannot find name 'Element'.
../node_modules/@types/googlemaps/index.d.ts(2398,29): error TS2304: Cannot find name 'Element'.
../node_modules/@types/googlemaps/index.d.ts(2455,37): error TS2304: Cannot find name 'HTMLInputElement'.
../node_modules/@types/googlemaps/index.d.ts(2616,40): error TS2304: Cannot find name 'HTMLDivElement'.
../node_modules/@types/googlemaps/index.d.ts(2663,37): error TS2304: Cannot find name 'HTMLInputElement'.
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! functions@ build: `tsc`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the functions@ build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! [PATH ON LOCAL MACHINE]\AppData\Roaming\npm-cache\_logs\2018-04-19T16_10_21_812Z-debug.log
Error: functions predeploy error: Command terminated with non-zero exit code2```
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 12
- Comments: 24 (4 by maintainers)
@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
tsc --skipLibCheck
instead oftsc
from withinfunctions/package.json
. This tells the typescript compiler to skip type checking of all declaration files.@dylanjmcdonald or put it in the tsconfig.json file:
Thanks for the heads up, btw đ
I fixed the same problem by adding: âtypeRootsâ: [ â./functions/node_modules/@typesâ ] to the tsconfig.json in functions folder
Just to clarify @gongevangen 's solution works but make sure to place the
"typeRoots"
key inside"compilerOptions"
:Kinda confused as to why this wouldnât be included in the boilerplateâŚor even mentioned anywhere in any of the Firebase tuts.
I fixed by adding
"dom"
tocompilerOptions.lib
in./functions/tsconfig.json
.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.
ânpm run buildâ uses regular âtscâ to build your files. This has nothing to do with Firebase or Cloud Functions.
I got the same issus thanks to @dylanjmcdonald I have solved it by using tsc --skipLibCheck
@dylanjmcdonald
tsc --skipLibCheck
in./functions/package.json
worked for me, thanks!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.
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.
Can confirm this is the only solution that worked for me! Thanks a bunch.
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?
Thank you so much
Itâs great that there are work-arounds for this this, but one of these solutions should really be in the
.tsconfig
generated byfirebase init
. Does anyone know how we can get this issue reopened?