node.js - firebase 函数模拟器版本冲突
问题描述
我正在 macOS High Sierra 版本 10.13.5 上开发。
当我尝试使用节点 v6.11.5 在本地运行函数时,会出现此错误:
⚠ 功能:无法启动模拟器。请使用 Node 版本 v6.9.1,你有 v6.11.5
然后当我使用 nvm 切换到 v6.9.1 版本时,
nvm use 6.9.1
rm -rf node_modules
npm install
npm uninstall firebase-tools --global
npm install firebase-tools --global
functions stop
npm uninstall -g @google-cloud/functions-emulator
npm install -g @google-cloud/functions-emulator
firebase login
firebase serve --only functions --debug
然后出现此错误:
运行模拟器需要 Node.js v6.11.5 或更高版本!
⚠ 功能:来自模拟器的错误。错误:模拟器崩溃!检查日志文件...
这是完整的日志:
[2018-06-30T15:43:38.960Z] ----------------------------------------------------------------------
[2018-06-30T15:43:38.964Z] Command: /Users/duyanh/.nvm/versions/node/v6.9.1/bin/node /Users/duyanh/.nvm/versions/node/v6.9.1/bin/firebase serve --only functions --debug
[2018-06-30T15:43:38.965Z] CLI Version: 3.19.1
[2018-06-30T15:43:38.965Z] Platform: darwin
[2018-06-30T15:43:38.965Z] Node Version: v6.9.1
[2018-06-30T15:43:38.966Z] Time: Sat Jun 30 2018 10:43:38 GMT-0500 (CDT)
[2018-06-30T15:43:38.966Z] ----------------------------------------------------------------------
[2018-06-30T15:43:38.978Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[2018-06-30T15:43:38.979Z] > authorizing via signed-in user
[2018-06-30T15:43:38.981Z] >>> HTTP REQUEST GET https://admin.firebase.com/v1/projects/dewey-nguyen
Sat Jun 30 2018 10:43:38 GMT-0500 (CDT)
[2018-06-30T15:43:39.348Z] <<< HTTP RESPONSE 200 server=nginx, date=Sat, 30 Jun 2018 15:43:39 GMT, content-type=application/json; charset=utf-8, content-length=111, connection=close, x-content-type-options=nosniff, strict-transport-security=max-age=31536000; includeSubdomains, cache-control=no-cache, no-store
[2018-06-30T15:43:39.350Z] >>> HTTP REQUEST GET https://admin.firebase.com/v1/database/dewey-nguyen/tokens
Sat Jun 30 2018 10:43:39 GMT-0500 (CDT)
[2018-06-30T15:43:39.953Z] <<< HTTP RESPONSE 200 server=nginx, date=Sat, 30 Jun 2018 15:43:39 GMT, content-type=application/json; charset=utf-8, content-length=260, connection=close, x-content-type-options=nosniff, strict-transport-security=max-age=31536000; includeSubdomains, cache-control=no-cache, no-store
[2018-06-30T15:43:39.955Z] >>> HTTP REQUEST GET https://cloudresourcemanager.googleapis.com/v1/projects/dewey-nguyen
Sat Jun 30 2018 10:43:39 GMT-0500 (CDT)
[2018-06-30T15:43:40.183Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Sat, 30 Jun 2018 15:43:40 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=quic=":443"; ma=2592000; v="43,42,41,39,35", accept-ranges=none, connection=close
=== Serving from '/Users/duyanh/workspace/dewey-nguyen'...
i functions: Preparing to emulate functions.
[2018-06-30T15:43:40.736Z] Fetching environment
[2018-06-30T15:43:40.739Z] >>> HTTP REQUEST GET https://mobilesdk-pa.googleapis.com/v1/projects/580895528558:getServerAppConfig
Sat Jun 30 2018 10:43:40 GMT-0500 (CDT)
[2018-06-30T15:43:41.167Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Sat, 30 Jun 2018 15:43:41 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=quic=":443"; ma=2592000; v="43,42,41,39,35", accept-ranges=none, connection=close
[2018-06-30T15:43:41.168Z] Starting @google-cloud/functions-emulator
Node.js v6.11.5 or greater is required to run the Emulator!
⚠ functions: Error from emulator. Error: Emulator crashed! Check the log file...
[2018-06-30T15:43:41.256Z] Error: Emulator crashed! Check the log file...
at ChildProcess.child.on (/Users/duyanh/.nvm/versions/node/v6.9.1/lib/node_modules/firebase-tools/node_modules/@google-cloud/functions-emulator/src/cli/controller.js:650:24)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
这是我的 package.json:
{
"name": "functions",
"description": "Cloud Functions for Firebase",
"scripts": {
...
},
"dependencies": {
"@google-cloud/vision": "^0.20.0",
"actions-on-google": "^2.2.0",
"bluebird": "^3.5.1",
"colors": "^1.3.0",
"dialogflow-fulfillment": "^0.4.1",
"firebase-admin": "~5.4.0",
"firebase-functions": "^1.1.0",
"googleapis": "^32.0.0",
"lodash": "^4.17.10",
"moment": "^2.22.2",
"winston": "^3.0.0"
},
"private": true,
"devDependencies": {
"@babel/cli": "^7.0.0-beta.51",
"@babel/core": "^7.0.0-beta.51",
"@babel/preset-env": "^7.0.0-beta.51",
"firebase-admin": "^5.4.3"
}
}
你能否给我一些关于发生了什么以及可能的解决方法的线索?
解决方案
推荐阅读
- slack-api - 从 Slack 请求消息范围
- spring - 迄今为止的spring boot 2.0 + thymeleaf unix epoch
- javascript - 如何在wordpress中设置自定义页面url
- robotframework - 在 Mac Safari 浏览器上执行 Robotscripts 很奇怪
- php - 根据首字母显示“名字”数据
- vba - Excel 宏根据单元格值验证 2 列
- python - 组合数据帧切片时 concat 和 np_r 之间的不同结果
- json - 在 NodeJS 中检索 POST 的响应
- javascript - 在Javascript中处理字符串中所有字母的出现
- javascript - 如何使用plotly / Python / Dash从原点到用户的鼠标坐标绘制一条线