I think so.
English in not my mother language, I use google translate to describe my question.
Try to deploy cloud functions, getting syntax errors not in my code but in actions-on-google.
Deploy successful at morning but fail afternoon.
I think I didn't modify code.
=== Deploying to 'my_project_id'...
i deploying database, functions, hosting
i database: checking rules syntax...
+ database: rules syntax for database my_project_id is valid
i functions: ensuring necessary APIs are enabled...
+ functions: all necessary APIs are enabled
i functions: preparing functions directory for uploading...
i functions: packaged functions (44.11 KB) for uploading
+ functions: functions folder uploaded successfully
i hosting[my_project_id]: beginning deploy...
i hosting[my_project_id]: found 4 files in public
+ hosting[my_project_id]: file upload complete
i database: releasing rules...
+ database: rules for database my_project_id released successfully
i functions: updating Node.js 6 function fakeauth(us-central1)...
i functions: updating Node.js 6 function faketoken(us-central1)...
i functions: updating Node.js 6 function smarthome(us-central1)...
i functions: updating Node.js 6 function requestsync(us-central1)...
i functions: updating Node.js 6 function reportstate(us-central1)...
! functions[smarthome(us-central1)]: Deployment error.
Function failed on loading user code. Error message: Code in file index.js can't
be loaded.
Is there a syntax error in your code?
Detailed stack trace: /user_code/node_modules/actions-on-google/node_modules/gax
ios/build/src/index.js:28
async function request(opts) {
^^^^^^^^
SyntaxError: Unexpected token function
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:549:28)
at Object.Module._extensions..js (module.js:586:10)
at Module.load (module.js:494:32)
at tryModuleLoad (module.js:453:12)
at Function.Module._load (module.js:445:3)
at Module.require (module.js:504:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/user_code/node_modules/actions-on-google/node_module
s/gtoken/build/src/index.js:18:18)
! functions[fakeauth(us-central1)]: Deployment error.
Function failed on loading user code. Error message: Code in file index.js can't
be loaded.
Is there a syntax error in your code?
Detailed stack trace: /user_code/node_modules/actions-on-google/node_modules/gax
ios/build/src/index.js:28
async function request(opts) {
^^^^^^^^
SyntaxError: Unexpected token function
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:549:28)
at Object.Module._extensions..js (module.js:586:10)
at Module.load (module.js:494:32)
at tryModuleLoad (module.js:453:12)
at Function.Module._load (module.js:445:3)
at Module.require (module.js:504:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/user_code/node_modules/actions-on-google/node_module
s/gtoken/build/src/index.js:18:18)
! functions[reportstate(us-central1)]: Deployment error.
Function failed on loading user code. Error message: Code in file index.js can't
be loaded.
Is there a syntax error in your code?
Detailed stack trace: /user_code/node_modules/actions-on-google/node_modules/gax
ios/build/src/index.js:28
async function request(opts) {
^^^^^^^^
SyntaxError: Unexpected token function
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:549:28)
at Object.Module._extensions..js (module.js:586:10)
at Module.load (module.js:494:32)
at tryModuleLoad (module.js:453:12)
at Function.Module._load (module.js:445:3)
at Module.require (module.js:504:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/user_code/node_modules/actions-on-google/node_module
s/gtoken/build/src/index.js:18:18)
! functions[requestsync(us-central1)]: Deployment error.
Function failed on loading user code. Error message: Code in file index.js can't
be loaded.
Is there a syntax error in your code?
Detailed stack trace: /user_code/node_modules/actions-on-google/node_modules/gax
ios/build/src/index.js:28
async function request(opts) {
^^^^^^^^
SyntaxError: Unexpected token function
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:549:28)
at Object.Module._extensions..js (module.js:586:10)
at Module.load (module.js:494:32)
at tryModuleLoad (module.js:453:12)
at Function.Module._load (module.js:445:3)
at Module.require (module.js:504:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/user_code/node_modules/actions-on-google/node_module
s/gtoken/build/src/index.js:18:18)
! functions[faketoken(us-central1)]: Deployment error.
Function failed on loading user code. Error message: Code in file index.js can't
be loaded.
Is there a syntax error in your code?
Detailed stack trace: /user_code/node_modules/actions-on-google/node_modules/gax
ios/build/src/index.js:28
async function request(opts) {
^^^^^^^^
SyntaxError: Unexpected token function
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:549:28)
at Object.Module._extensions..js (module.js:586:10)
at Module.load (module.js:494:32)
at tryModuleLoad (module.js:453:12)
at Function.Module._load (module.js:445:3)
at Module.require (module.js:504:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/user_code/node_modules/actions-on-google/node_module
s/gtoken/build/src/index.js:18:18)
Functions deploy had errors with the following functions:
fakeauth
faketoken
reportstate
requestsync
smarthome
To try redeploying those functions, run:
firebase deploy --only functions:fakeauth,functions:faketoken,functions:repo
rtstate,functions:requestsync,functions:smarthome
To continue deploying other features (such as database), run:
firebase deploy --except functions
my package.json:
{
"name": "smarthome-washer",
"description": "Codelab for controlling devices through the Google Assistant",
"engines": {
"node": "6"
},
"dependencies": {
"actions-on-google": "2.6.0",
"ajv": "^5.0.0",
"cors": "^2.8.4",
"firebase-admin": "^5.8.2",
"firebase-functions": "^2.3.0",
"googleapis": "^27.0.0"
},
"private": true,
"devDependencies": {
"eslint": "^4.19.1",
"eslint-config-google": "^0.9.1"
}
}
I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
Myself as well faced the same issue, but I'm able to deploy to the cloud functions, and one of my function throwing the same error all the sudden, and it was working just fine before that.
ERROR
/user_code/node_modules/firebase-admin/node_modules/gaxios/build/src/index.js:28
async function request(opts) {
^^^^^^^^
SyntaxError: Unexpected token function
We managed to get around the issue by changing the node engine version in the package.json.
"engines": {
"node": "8"
},
i functions: updating Node.js 6 function fakeauth(us-central1)...
i functions: updating Node.js 6 function faketoken(us-central1)...
i functions: updating Node.js 6 function smarthome(us-central1)...
i functions: updating Node.js 6 function requestsync(us-central1)...
i functions: updating Node.js 6 function reportstate(us-central1)...
You're trying to use async/await syntax in Node 6. You have to use Node 8 for that. Solution suggested by @brettcallanan is correct.
Also note that Node 6 support is deprecated in Cloud Functions. Node 8 is the recommended runtime.
Most helpful comment
We managed to get around the issue by changing the node engine version in the package.json.
"engines": { "node": "8" },