刚刚升级的Firebase功能并出现错误

时间:2019-04-19 06:10:40

标签: firebase google-cloud-functions

我正在尝试从节点6升级到节点8,并且正在关注docs。我刚刚在CLI中更新了firebase-toolsfirebase-functions,并将"engines": { "node": "8" }添加到我的 project / functions package.json文件中,出现以下错误:

PS C:\program files\git\projects\qmn> firebase deploy

=== Deploying to 'quizmenot-79ee9'...

i  deploying storage, firestore, functions, hosting
Running command: npm --prefix "$RESOURCE_DIR" run build

> functions@ build C:\program files\git\projects\qmn\functions
> tsc

node_modules/firebase-functions/lib/function-builder.d.ts(61,93): error TS1005: ';' expected.
node_modules/firebase-functions/lib/function-builder.d.ts(61,94): error TS1003: Identifier expected.
node_modules/firebase-functions/lib/function-builder.d.ts(61,114): error TS1005: ';' expected.
node_modules/gaxios/build/src/index.d.ts(14,66): error TS1005: '>' expected.
node_modules/gaxios/build/src/index.d.ts(14,103): error TS1109: Expression expected.
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!     C:\Users\FiringBlanks\AppData\Roaming\npm-cache\_logs\2019-04-19T05_57_15_561Z-debug.log

Error: functions predeploy error: Command terminated with non-zero exit code2

来自C:\Users\FiringBlanks\AppData\Roaming\npm-cache\_logs的更多日志信息

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   '--prefix',
1 verbose cli   'C:\\program files\\git\\projects\\qmn\\functions',
1 verbose cli   'run',
1 verbose cli   'build' ]
2 info using npm@6.4.1
3 info using node@v8.12.0
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle functions@~prebuild: functions@
6 info lifecycle functions@~build: functions@
7 verbose lifecycle functions@~build: unsafe-perm in lifecycle true
8 verbose lifecycle functions@~build: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\program files\git\projects\qmn\functions\node_modules\.bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\nodejs\;C:\Program Files\Git\cmd;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Users\FiringBlanks\AppData\Local\Microsoft\WindowsApps;C:\Users\FiringBlanks\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\FiringBlanks\AppData\Roaming\npm;C:\Users\FiringBlanks\AppData\Local\Google\Cloud SDK\google-cloud-sdk\bin
9 verbose lifecycle functions@~build: CWD: C:\program files\git\projects\qmn\functions
10 silly lifecycle functions@~build: Args: [ '/d /s /c', 'tsc' ]
11 silly lifecycle functions@~build: Returned: code: 2  signal: null
12 info lifecycle functions@~build: Failed to exec build script
13 verbose stack Error: functions@ build: `tsc`
13 verbose stack Exit status 2
13 verbose stack     at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:301:16)
13 verbose stack     at emitTwo (events.js:126:13)
13 verbose stack     at EventEmitter.emit (events.js:214:7)
13 verbose stack     at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack     at emitTwo (events.js:126:13)
13 verbose stack     at ChildProcess.emit (events.js:214:7)
13 verbose stack     at maybeClose (internal/child_process.js:915:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
14 verbose pkgid functions@
15 verbose cwd C:\program files\git\projects\qmn
16 verbose Windows_NT 10.0.17134
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "--prefix" "C:\\program files\\git\\projects\\qmn\\functions" "run" "build"
18 verbose node v8.12.0
19 verbose npm  v6.4.1
20 error code ELIFECYCLE
21 error errno 2
22 error functions@ build: `tsc`
22 error Exit status 2
23 error Failed at the functions@ build script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 2, true ]

2 个答案:

答案 0 :(得分:0)

看起来像是Typescript编译器错误。我升级firebase-functions时遇到了类似的错误。

在函数文件夹的package.json中检查您的Typescript版本。

这些版本适用于Node 8:

"firebase-functions": "^2.1.0"
"typescript": "^3.1.1"

答案 1 :(得分:0)

在这里找到解决方案:https://github.com/firebase/firebase-functions/issues/404

这是打字稿版本问题。最新的(3.4.4)不起作用。安装v3.3.1即可。我使用了以下内容:

npm install --save typescript@3.3.1

npm install --save-dev typescript@3.3.1

在当前项目的根文件夹和/ functions目录中。

现在部署很好。