在 firebase 云功能启动期间安装 npm 依赖项时出错

Error in installation of npm dependecies during firebase cloud functions initiation

我正在尝试初始化一个 firebase 云函数和依赖项安装总是失败的部分。它总是显示

这是我的package.json

{
"name": "functions",
"description": "Cloud Functions for Firebase",
"dependencies": {
"firebase-admin": "~4.2.1",
"firebase-functions": "^0.5.7"
},
"private": true
}

以下是安装过程中创建的完整日志:

0 info it worked if it ends with ok
1 verbose cli [ 'C:\Program Files\nodejs\node.exe',
1 verbose cli   'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js',
1 verbose cli   'install' ]
2 info using npm@5.3.0
3 info using node@v8.3.0
4 verbose npm-session 9486ab817502fd95
5 silly install runPreinstallTopLevelLifecycles
6 silly preinstall functions@
7 info lifecycle functions@~preinstall: functions@
8 silly install loadCurrentTree
9 silly install readLocalPackageData
10 silly install loadIdealTree
11 silly install cloneCurrentTreeToIdealTree
12 silly install loadShrinkwrap
13 silly install loadAllDepsIntoIdealTree
14 http fetch GET 304 https://registry.npmjs.org/firebase-functions 514ms (from cache)
15 http fetch GET 304 https://registry.npmjs.org/firebase-admin 532ms (from cache)
16 silly pacote range manifest for firebase-functions@^0.5.7 fetched in 524ms
17 http fetch GET 200 https://registry.npmjs.org/firebase-admin/-/firebase-admin-4.2.1.tgz 41ms (from cache)
18 silly fetchPackageMetaData error for firebase-admin@~4.2.1 unexpected end of file
19 http fetch GET 304 https://registry.npmjs.org/lodash 292ms (from cache)
20 http fetch GET 304 https://registry.npmjs.org/jsonwebtoken 299ms (from cache)
21 http fetch GET 304 https://registry.npmjs.org/express 303ms (from cache)
22 silly pacote range manifest for lodash@^4.6.1 fetched in 307ms
23 silly pacote range manifest for jsonwebtoken@^7.1.9 fetched in 309ms
24 silly pacote range manifest for express@^4.0.33 fetched in 318ms
25 http fetch GET 304 https://registry.npmjs.org/joi 125ms (from cache)
26 silly pacote range manifest for joi@^6.10.1 fetched in 143ms
27 http fetch GET 304 https://registry.npmjs.org/sha1 454ms (from cache)
28 silly pacote range manifest for sha1@^1.1.1 fetched in 460ms
29 http fetch GET 304 https://registry.npmjs.org/xtend 169ms (from cache)
30 silly pacote range manifest for xtend@^4.0.1 fetched in 174ms
31 http fetch GET 304 https://registry.npmjs.org/ms 184ms (from cache)
32 silly pacote range manifest for ms@^2.0.0 fetched in 188ms
33 http fetch GET 304 https://registry.npmjs.org/accepts 73ms (from cache)
34 silly pacote range manifest for accepts@~1.3.3 fetched in 77ms
35 http fetch GET 304 https://registry.npmjs.org/array-flatten 69ms (from cache)
36 silly pacote version manifest for array-flatten@1.1.1 fetched in 76ms
37 http fetch GET 304 https://registry.npmjs.org/lodash.once 250ms (from cache)
38 silly pacote range manifest for lodash.once@^4.0.0 fetched in 254ms
39 http fetch GET 304 https://registry.npmjs.org/content-disposition 85ms (from cache)
40 silly pacote version manifest for content-disposition@0.5.2 fetched in 89ms
41 http fetch GET 304 https://registry.npmjs.org/content-type 83ms (from cache)
42 silly pacote range manifest for content-type@~1.0.2 fetched in 87ms
43 http fetch GET 304 https://registry.npmjs.org/cookie 90ms (from cache)
44 silly pacote version manifest for cookie@0.3.1 fetched in 94ms
45 http fetch GET 304 https://registry.npmjs.org/cookie-signature 104ms (from cache)
46 silly pacote version manifest for cookie-signature@1.0.6 fetched in 111ms
47 http fetch GET 304 https://registry.npmjs.org/debug 97ms (from cache)
48 silly pacote version manifest for debug@2.6.8 fetched in 101ms
49 http fetch GET 304 https://registry.npmjs.org/depd 89ms (from cache)
50 silly pacote range manifest for depd@~1.1.1 fetched in 95ms
51 http fetch GET 304 https://registry.npmjs.org/encodeurl 95ms (from cache)
52 silly pacote range manifest for encodeurl@~1.0.1 fetched in 99ms
53 http fetch GET 304 https://registry.npmjs.org/escape-html 91ms (from cache)
54 silly pacote range manifest for escape-html@~1.0.3 fetched in 94ms
55 http fetch GET 304 https://registry.npmjs.org/etag 82ms (from cache)
56 silly pacote range manifest for etag@~1.8.0 fetched in 86ms
57 http fetch GET 304 https://registry.npmjs.org/finalhandler 88ms (from cache)
58 silly pacote range manifest for finalhandler@~1.0.4 fetched in 94ms
59 http fetch GET 304 https://registry.npmjs.org/fresh 93ms (from cache)
60 silly pacote version manifest for fresh@0.5.0 fetched in 98ms
61 http fetch GET 304 https://registry.npmjs.org/merge-descriptors 92ms (from cache)
62 silly pacote version manifest for merge-descriptors@1.0.1 fetched in 97ms
63 http fetch GET 304 https://registry.npmjs.org/methods 92ms (from cache)
64 silly pacote range manifest for methods@~1.1.2 fetched in 96ms
65 http fetch GET 304 https://registry.npmjs.org/on-finished 90ms (from cache)
66 silly pacote range manifest for on-finished@~2.3.0 fetched in 93ms
67 http fetch GET 304 https://registry.npmjs.org/parseurl 91ms (from cache)
68 silly pacote range manifest for parseurl@~1.3.1 fetched in 95ms
69 http fetch GET 304 https://registry.npmjs.org/path-to-regexp 89ms (from cache)
70 http fetch GET 304 https://registry.npmjs.org/@types%2fsha1 867ms (from cache)
71 silly pacote range manifest for @types/sha1@^1.1.0 fetched in 879ms
72 silly pacote version manifest for path-to-regexp@0.1.7 fetched in 104ms
73 http fetch GET 304 https://registry.npmjs.org/proxy-addr 121ms (from cache)
74 http fetch GET 304 https://registry.npmjs.org/@types%2flodash 912ms (from cache)
75 silly pacote range manifest for proxy-addr@~1.1.5 fetched in 127ms
76 silly pacote range manifest for @types/lodash@^4.14.34 fetched in 920ms
77 http fetch GET 304 https://registry.npmjs.org/qs 102ms (from cache)
78 silly pacote version manifest for qs@6.5.0 fetched in 109ms
79 http fetch GET 304 https://registry.npmjs.org/range-parser 98ms (from cache)
80 silly pacote range manifest for range-parser@~1.2.0 fetched in 104ms
81 http fetch GET 304 https://registry.npmjs.org/send 96ms (from cache)
82 silly pacote version manifest for send@0.15.4 fetched in 101ms
83 http fetch GET 304 https://registry.npmjs.org/setprototypeof 87ms (from cache)
84 http fetch GET 304 https://registry.npmjs.org/serve-static 88ms (from cache)
85 silly pacote version manifest for setprototypeof@1.0.3 fetched in 93ms
86 silly pacote version manifest for serve-static@1.12.4 fetched in 95ms
87 http fetch GET 304 https://registry.npmjs.org/statuses 94ms (from cache)
88 silly pacote range manifest for statuses@~1.3.1 fetched in 101ms
89 http fetch GET 304 https://registry.npmjs.org/type-is 97ms (from cache)
90 http fetch GET 304 https://registry.npmjs.org/utils-merge 98ms (from cache)
91 silly pacote range manifest for type-is@~1.6.15 fetched in 108ms
92 http fetch GET 304 https://registry.npmjs.org/vary 95ms (from cache)
93 http fetch GET 304 https://registry.npmjs.org/@types%2fexpress 1036ms (from cache)
94 http fetch GET 200 https://registry.npmjs.org/@types%2fjsonwebtoken 1038ms
95 silly pacote version manifest for utils-merge@1.0.0 fetched in 110ms
96 silly pacote range manifest for vary@~1.1.1 fetched in 104ms
97 silly pacote range manifest for @types/jsonwebtoken@^7.1.32 fetched in 1046ms
98 silly pacote range manifest for @types/express@^4.0.33 fetched in 1052ms
99 silly pacote version manifest for ms@2.0.0 fetched in 16ms
100 http fetch GET 304 https://registry.npmjs.org/hoek 107ms (from cache)
101 http fetch GET 304 https://registry.npmjs.org/topo 108ms (from cache)
102 silly pacote range manifest for hoek@2.x.x fetched in 124ms
103 silly pacote range manifest for topo@1.x.x fetched in 113ms
104 http fetch GET 304 https://registry.npmjs.org/isemail 114ms (from cache)
105 silly pacote range manifest for isemail@1.x.x fetched in 129ms
106 http fetch GET 304 https://registry.npmjs.org/moment 125ms (from cache)
107 http fetch GET 304 https://registry.npmjs.org/charenc 121ms (from cache)
108 silly pacote range manifest for moment@2.x.x fetched in 133ms
109 http fetch GET 304 https://registry.npmjs.org/jws 843ms (from cache)
110 silly pacote range manifest for charenc@>= 0.0.1 fetched in 131ms
111 silly pacote range manifest for jws@^3.1.4 fetched in 850ms
112 http fetch GET 304 https://registry.npmjs.org/mime-types 122ms (from cache)
113 http fetch GET 304 https://registry.npmjs.org/negotiator 122ms (from cache)
114 http fetch GET 304 https://registry.npmjs.org/crypt 129ms (from cache)
115 silly pacote version manifest for negotiator@0.6.1 fetched in 130ms
116 silly pacote range manifest for mime-types@~2.1.11 fetched in 132ms
117 silly pacote range manifest for crypt@>= 0.0.1 fetched in 139ms
118 silly pacote range manifest for mime-types@~2.1.15 fetched in 7ms
119 http fetch GET 304 https://registry.npmjs.org/unpipe 130ms (from cache)
120 silly pacote range manifest for unpipe@~1.0.0 fetched in 135ms
121 http fetch GET 304 https://registry.npmjs.org/ee-first 116ms (from cache)
122 silly pacote version manifest for ee-first@1.1.1 fetched in 120ms
123 http fetch GET 304 https://registry.npmjs.org/forwarded 130ms (from cache)
124 silly pacote range manifest for forwarded@~0.1.0 fetched in 133ms
125 http fetch GET 304 https://registry.npmjs.org/ipaddr.js 138ms (from cache)
126 silly pacote version manifest for ipaddr.js@1.4.0 fetched in 142ms
127 http fetch GET 304 https://registry.npmjs.org/destroy 152ms (from cache)
128 silly pacote range manifest for destroy@~1.0.4 fetched in 159ms
129 http fetch GET 304 https://registry.npmjs.org/http-errors 156ms (from cache)
130 http fetch GET 304 https://registry.npmjs.org/mime 149ms (from cache)
131 silly pacote range manifest for http-errors@~1.6.2 fetched in 162ms
132 http fetch GET 304 https://registry.npmjs.org/media-typer 152ms (from cache)
133 silly pacote version manifest for mime@1.3.4 fetched in 156ms
134 silly pacote version manifest for depd@1.1.1 fetched in 6ms
135 silly pacote version manifest for media-typer@0.3.0 fetched in 160ms
136 silly pacote range manifest for statuses@>= 1.3.1 < 2 fetched in 3ms
137 http fetch GET 304 https://registry.npmjs.org/safe-buffer 157ms (from cache)
138 silly pacote range manifest for safe-buffer@^5.0.1 fetched in 168ms
139 http fetch GET 304 https://registry.npmjs.org/inherits 141ms (from cache)
140 http fetch GET 304 https://registry.npmjs.org/mime-db 154ms (from cache)
141 silly pacote version manifest for inherits@2.0.3 fetched in 145ms
142 silly pacote range manifest for mime-db@~1.29.0 fetched in 159ms
143 http fetch GET 304 https://registry.npmjs.org/jwa 280ms (from cache)
144 silly pacote range manifest for jwa@^1.1.4 fetched in 284ms
145 http fetch GET 304 https://registry.npmjs.org/ecdsa-sig-formatter 164ms (from cache)
146 silly pacote version manifest for ecdsa-sig-formatter@1.0.9 fetched in 169ms
147 http fetch GET 304 https://registry.npmjs.org/buffer-equal-constant-time 256ms (from cache)
148 silly pacote version manifest for buffer-equal-constant-time@1.0.1 fetched in 261ms
149 http fetch GET 304 https://registry.npmjs.org/@types%2fnode 839ms (from cache)
150 silly pacote range manifest for @types/node@* fetched in 848ms
151 http fetch GET 304 https://registry.npmjs.org/base64url 884ms (from cache)
152 http fetch GET 304 https://registry.npmjs.org/base64url 571ms (from cache)
153 http fetch GET 304 https://registry.npmjs.org/@types%2fserve-static 914ms (from cache)
154 http fetch GET 304 https://registry.npmjs.org/@types%2fexpress-serve-static-core 901ms (from cache)
155 silly pacote range manifest for base64url@^2.0.0 fetched in 894ms
156 silly pacote version manifest for base64url@2.0.0 fetched in 580ms
157 silly pacote range manifest for @types/serve-static@* fetched in 918ms
158 silly pacote range manifest for @types/express-serve-static-core@* fetched in 905ms
159 http fetch GET 304 https://registry.npmjs.org/@types%2fmime 908ms (from cache)
160 silly pacote range manifest for @types/mime@* fetched in 919ms
161 silly pacote range manifest for firebase-functions@^0.5.7 fetched in 13ms
162 silly resolveWithNewModule firebase-functions@0.5.9 checking installable status
163 http fetch GET 200 https://registry.npmjs.org/firebase-admin/-/firebase-admin-4.2.1.tgz 18ms (from cache)
164 silly fetchPackageMetaData error for firebase-admin@~4.2.1 unexpected end of file
165 verbose stack Error: unexpected end of file
165 verbose stack     at Gunzip.zlibOnError (zlib.js:152:15)
166 verbose cwd C:\Users\eugene.m.aquilino\pal-poc\functions
167 verbose Windows_NT 10.0.14393
168 verbose argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "install"
169 verbose node v8.3.0
170 verbose npm  v5.3.0
171 error code Z_BUF_ERROR
172 error errno -5
173 error unexpected end of file
174 verbose exit [ -5, true ]

谁能帮我找出错误?谢谢!

有时(tarball)下载可能会损坏,当它们损坏时,您通常会遇到某种与 zlib 相关的错误。发生这种情况时,第一步是 运行 npm cache clean 删除任何可能 t运行 的下载,然后重新尝试 npm install ....