我正在使用macOS High Sierra版本10.13.5进行开发。
当我尝试使用节点v6.11.5在本地运行函数时,出现此错误:
⚠函数:无法启动模拟器。请使用Node版本v6.9.1,您拥有v6.11.5
然后,当我使用nvm切换到v6.9.1版本时,
Exception in thread "main" com.hp.hpl.jena.query.QueryParseException: Encountered "(" at line 1, column 212.
Was expecting one of:
<VAR1> ...
<VAR2> ...
"distinct" ...
"reduced" ...
"*" ...
然后显示此错误:
要运行仿真器,需要Node.js v6.11.5或更高版本!
⚠函数:来自仿真器的错误。错误:模拟器崩溃!检查日志文件...
这是完整的日志:
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
这是我的package.json:
[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)
能否请您提供一些正在发生的事情以及修复它的可能方法的线索?