Google Firebase functions to iot device send config
up vote
0
down vote
favorite
I am trying to use firebase functions to send config to an Iot device.Here is the tutorial which i am trying to use.This is the Node js code which i am deploying
The tutorial says after, after deployment whatever change i will do to my firebase database it will get sent to the iot device as device config.
registryid is INTERNET_OF_BULBS.
Iot device name is Iot-device-1.
The actual code in the tutorial doesnt work for deployment.So I removed the import modules part and used require.
The tutorial does these imports.
import * as admin from "firebase-admin";
import * as functions from 'firebase-functions';
import runInDebugContext from 'vm';
import DeviceManager from './devices';
how do i import DeviceManager from './devices';
so i am doing only 2 imports.Otherwise ,if i use import in my index.js it gives error when deploying.
1:1 error Parsing error: 'import' and 'export' may appear only with 'sourceType: module'
Below is my index.js file.
const admin =require('firebase-admin');
const functions =require('firebase-functions');
admin.initializeApp();
// create a device manager instance with a registry id, optionally pass a region
const dm = new DeviceManager('INTERNET_OF_BULBS');
const firestore = admin.firestore();
// start cloud function
exports.configUpdate = functions.firestore
// assumes a document whose ID is the same as the deviceid
.document('device-configs/Iot-device-1')
.onWrite((change,context) =>
var beforeData = change.before.val(); // data before the write
var afterData = change.after.val();
if (context)
await dm.setAuth();
console.log(context.params.deviceId);
// get the new config data
const configData = change.after.data();
return dm.updateConfig(context.params.deviceId, configData);
else
throw(Error("no context from trigger"));
)
Here is the error on my shell when i am trying to deploy,the above code.
firebase deploy
=== Deploying to 'wifi-lights-88783'...
i deploying functions
Running command: npm --prefix "$RESOURCE_DIR" run lint
> functions@ lint /home/suposhmehta/fire/functions
> eslint .
/home/suposhmehta/fire/functions/index.js
17:13 error Parsing error: Unexpected token dm
✖ 1 problem (1 error, 0 warnings)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! functions@ lint: `eslint .`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the functions@ lint 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! /home/suposhmehta/.npm/_logs/2018-11-10T09_38_15_585Z-debug.log
Error: functions predeploy error: Command terminated with non-zero exit code1
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/nvm/versions/node/v8.9.4/bin/node',
1 verbose cli '/usr/local/nvm/versions/node/v8.9.4/bin/npm',
1 verbose cli '--prefix',
1 verbose cli '/home/suposhmehta/fire/functions',
1 verbose cli 'run',
1 verbose cli 'lint' ]
2 info using npm@5.6.0
3 info using node@v8.9.4
4 verbose run-script [ 'prelint', 'lint', 'postlint' ]
5 info lifecycle functions@~prelint: functions@
6 info lifecycle functions@~lint: functions@
7 verbose lifecycle functions@~lint: unsafe-perm in lifecycle true
8 verbose lifecycle functions@~lint: PATH: /usr/local/nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/suposhmehta/fire/functions/node_
modules/.bin:/home/suposhmehta/gopath/bin:/google/gopath/bin:/google/google-cloud-sdk/bin:/usr/local/go/bin:/opt/gradle/bin:/opt/maven/bin:/usr/local/sbin:/usr/local/bin:/usr/sbi
n:/usr/bin:/sbin:/bin:/usr/local/nvm/versions/node/v8.9.4/bin:/google/go_appengine:/google/google_appengine
9 verbose lifecycle functions@~lint: CWD: /home/suposhmehta/fire/functions
10 silly lifecycle functions@~lint: Args: [ '-c', 'eslint .' ]
11 silly lifecycle functions@~lint: Returned: code: 1 signal: null
12 info lifecycle functions@~lint: Failed to exec lint script
13 verbose stack Error: functions@ lint: `eslint .`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (/usr/local/nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:285: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> (/usr/local/nvm/versions/node/v8.9.4/lib/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:925:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
14 verbose pkgid functions@
15 verbose cwd /home/suposhmehta/fire
16 verbose Linux 4.14.33+
17 verbose argv "/usr/local/nvm/versions/node/v8.9.4/bin/node" "/usr/local/nvm/versions/node/v8.9.4/bin/npm" "--prefix" "/home/suposhmehta/fire/functions" "run" "lint"
18 verbose node v8.9.4
19 verbose npm v5.6.0
20 error code ELIFECYCLE
21 error errno 1
22 error functions@ lint: `eslint .`
22 error Exit status 1
23 error Failed at the functions@ lint script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
How do i get rid of these issues?
Please Help.
node.js firebase firebase-authentication google-cloud-functions google-cloud-iot
add a comment |
up vote
0
down vote
favorite
I am trying to use firebase functions to send config to an Iot device.Here is the tutorial which i am trying to use.This is the Node js code which i am deploying
The tutorial says after, after deployment whatever change i will do to my firebase database it will get sent to the iot device as device config.
registryid is INTERNET_OF_BULBS.
Iot device name is Iot-device-1.
The actual code in the tutorial doesnt work for deployment.So I removed the import modules part and used require.
The tutorial does these imports.
import * as admin from "firebase-admin";
import * as functions from 'firebase-functions';
import runInDebugContext from 'vm';
import DeviceManager from './devices';
how do i import DeviceManager from './devices';
so i am doing only 2 imports.Otherwise ,if i use import in my index.js it gives error when deploying.
1:1 error Parsing error: 'import' and 'export' may appear only with 'sourceType: module'
Below is my index.js file.
const admin =require('firebase-admin');
const functions =require('firebase-functions');
admin.initializeApp();
// create a device manager instance with a registry id, optionally pass a region
const dm = new DeviceManager('INTERNET_OF_BULBS');
const firestore = admin.firestore();
// start cloud function
exports.configUpdate = functions.firestore
// assumes a document whose ID is the same as the deviceid
.document('device-configs/Iot-device-1')
.onWrite((change,context) =>
var beforeData = change.before.val(); // data before the write
var afterData = change.after.val();
if (context)
await dm.setAuth();
console.log(context.params.deviceId);
// get the new config data
const configData = change.after.data();
return dm.updateConfig(context.params.deviceId, configData);
else
throw(Error("no context from trigger"));
)
Here is the error on my shell when i am trying to deploy,the above code.
firebase deploy
=== Deploying to 'wifi-lights-88783'...
i deploying functions
Running command: npm --prefix "$RESOURCE_DIR" run lint
> functions@ lint /home/suposhmehta/fire/functions
> eslint .
/home/suposhmehta/fire/functions/index.js
17:13 error Parsing error: Unexpected token dm
✖ 1 problem (1 error, 0 warnings)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! functions@ lint: `eslint .`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the functions@ lint 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! /home/suposhmehta/.npm/_logs/2018-11-10T09_38_15_585Z-debug.log
Error: functions predeploy error: Command terminated with non-zero exit code1
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/nvm/versions/node/v8.9.4/bin/node',
1 verbose cli '/usr/local/nvm/versions/node/v8.9.4/bin/npm',
1 verbose cli '--prefix',
1 verbose cli '/home/suposhmehta/fire/functions',
1 verbose cli 'run',
1 verbose cli 'lint' ]
2 info using npm@5.6.0
3 info using node@v8.9.4
4 verbose run-script [ 'prelint', 'lint', 'postlint' ]
5 info lifecycle functions@~prelint: functions@
6 info lifecycle functions@~lint: functions@
7 verbose lifecycle functions@~lint: unsafe-perm in lifecycle true
8 verbose lifecycle functions@~lint: PATH: /usr/local/nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/suposhmehta/fire/functions/node_
modules/.bin:/home/suposhmehta/gopath/bin:/google/gopath/bin:/google/google-cloud-sdk/bin:/usr/local/go/bin:/opt/gradle/bin:/opt/maven/bin:/usr/local/sbin:/usr/local/bin:/usr/sbi
n:/usr/bin:/sbin:/bin:/usr/local/nvm/versions/node/v8.9.4/bin:/google/go_appengine:/google/google_appengine
9 verbose lifecycle functions@~lint: CWD: /home/suposhmehta/fire/functions
10 silly lifecycle functions@~lint: Args: [ '-c', 'eslint .' ]
11 silly lifecycle functions@~lint: Returned: code: 1 signal: null
12 info lifecycle functions@~lint: Failed to exec lint script
13 verbose stack Error: functions@ lint: `eslint .`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (/usr/local/nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:285: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> (/usr/local/nvm/versions/node/v8.9.4/lib/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:925:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
14 verbose pkgid functions@
15 verbose cwd /home/suposhmehta/fire
16 verbose Linux 4.14.33+
17 verbose argv "/usr/local/nvm/versions/node/v8.9.4/bin/node" "/usr/local/nvm/versions/node/v8.9.4/bin/npm" "--prefix" "/home/suposhmehta/fire/functions" "run" "lint"
18 verbose node v8.9.4
19 verbose npm v5.6.0
20 error code ELIFECYCLE
21 error errno 1
22 error functions@ lint: `eslint .`
22 error Exit status 1
23 error Failed at the functions@ lint script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
How do i get rid of these issues?
Please Help.
node.js firebase firebase-authentication google-cloud-functions google-cloud-iot
I am doing all of this in google cloud shell.
– suposh mehta
Nov 10 at 10:07
Google's tutorial link cloud.google.com/community/tutorials/cloud-iot-firestore-config
– suposh mehta
Nov 13 at 7:45
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am trying to use firebase functions to send config to an Iot device.Here is the tutorial which i am trying to use.This is the Node js code which i am deploying
The tutorial says after, after deployment whatever change i will do to my firebase database it will get sent to the iot device as device config.
registryid is INTERNET_OF_BULBS.
Iot device name is Iot-device-1.
The actual code in the tutorial doesnt work for deployment.So I removed the import modules part and used require.
The tutorial does these imports.
import * as admin from "firebase-admin";
import * as functions from 'firebase-functions';
import runInDebugContext from 'vm';
import DeviceManager from './devices';
how do i import DeviceManager from './devices';
so i am doing only 2 imports.Otherwise ,if i use import in my index.js it gives error when deploying.
1:1 error Parsing error: 'import' and 'export' may appear only with 'sourceType: module'
Below is my index.js file.
const admin =require('firebase-admin');
const functions =require('firebase-functions');
admin.initializeApp();
// create a device manager instance with a registry id, optionally pass a region
const dm = new DeviceManager('INTERNET_OF_BULBS');
const firestore = admin.firestore();
// start cloud function
exports.configUpdate = functions.firestore
// assumes a document whose ID is the same as the deviceid
.document('device-configs/Iot-device-1')
.onWrite((change,context) =>
var beforeData = change.before.val(); // data before the write
var afterData = change.after.val();
if (context)
await dm.setAuth();
console.log(context.params.deviceId);
// get the new config data
const configData = change.after.data();
return dm.updateConfig(context.params.deviceId, configData);
else
throw(Error("no context from trigger"));
)
Here is the error on my shell when i am trying to deploy,the above code.
firebase deploy
=== Deploying to 'wifi-lights-88783'...
i deploying functions
Running command: npm --prefix "$RESOURCE_DIR" run lint
> functions@ lint /home/suposhmehta/fire/functions
> eslint .
/home/suposhmehta/fire/functions/index.js
17:13 error Parsing error: Unexpected token dm
✖ 1 problem (1 error, 0 warnings)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! functions@ lint: `eslint .`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the functions@ lint 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! /home/suposhmehta/.npm/_logs/2018-11-10T09_38_15_585Z-debug.log
Error: functions predeploy error: Command terminated with non-zero exit code1
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/nvm/versions/node/v8.9.4/bin/node',
1 verbose cli '/usr/local/nvm/versions/node/v8.9.4/bin/npm',
1 verbose cli '--prefix',
1 verbose cli '/home/suposhmehta/fire/functions',
1 verbose cli 'run',
1 verbose cli 'lint' ]
2 info using npm@5.6.0
3 info using node@v8.9.4
4 verbose run-script [ 'prelint', 'lint', 'postlint' ]
5 info lifecycle functions@~prelint: functions@
6 info lifecycle functions@~lint: functions@
7 verbose lifecycle functions@~lint: unsafe-perm in lifecycle true
8 verbose lifecycle functions@~lint: PATH: /usr/local/nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/suposhmehta/fire/functions/node_
modules/.bin:/home/suposhmehta/gopath/bin:/google/gopath/bin:/google/google-cloud-sdk/bin:/usr/local/go/bin:/opt/gradle/bin:/opt/maven/bin:/usr/local/sbin:/usr/local/bin:/usr/sbi
n:/usr/bin:/sbin:/bin:/usr/local/nvm/versions/node/v8.9.4/bin:/google/go_appengine:/google/google_appengine
9 verbose lifecycle functions@~lint: CWD: /home/suposhmehta/fire/functions
10 silly lifecycle functions@~lint: Args: [ '-c', 'eslint .' ]
11 silly lifecycle functions@~lint: Returned: code: 1 signal: null
12 info lifecycle functions@~lint: Failed to exec lint script
13 verbose stack Error: functions@ lint: `eslint .`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (/usr/local/nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:285: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> (/usr/local/nvm/versions/node/v8.9.4/lib/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:925:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
14 verbose pkgid functions@
15 verbose cwd /home/suposhmehta/fire
16 verbose Linux 4.14.33+
17 verbose argv "/usr/local/nvm/versions/node/v8.9.4/bin/node" "/usr/local/nvm/versions/node/v8.9.4/bin/npm" "--prefix" "/home/suposhmehta/fire/functions" "run" "lint"
18 verbose node v8.9.4
19 verbose npm v5.6.0
20 error code ELIFECYCLE
21 error errno 1
22 error functions@ lint: `eslint .`
22 error Exit status 1
23 error Failed at the functions@ lint script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
How do i get rid of these issues?
Please Help.
node.js firebase firebase-authentication google-cloud-functions google-cloud-iot
I am trying to use firebase functions to send config to an Iot device.Here is the tutorial which i am trying to use.This is the Node js code which i am deploying
The tutorial says after, after deployment whatever change i will do to my firebase database it will get sent to the iot device as device config.
registryid is INTERNET_OF_BULBS.
Iot device name is Iot-device-1.
The actual code in the tutorial doesnt work for deployment.So I removed the import modules part and used require.
The tutorial does these imports.
import * as admin from "firebase-admin";
import * as functions from 'firebase-functions';
import runInDebugContext from 'vm';
import DeviceManager from './devices';
how do i import DeviceManager from './devices';
so i am doing only 2 imports.Otherwise ,if i use import in my index.js it gives error when deploying.
1:1 error Parsing error: 'import' and 'export' may appear only with 'sourceType: module'
Below is my index.js file.
const admin =require('firebase-admin');
const functions =require('firebase-functions');
admin.initializeApp();
// create a device manager instance with a registry id, optionally pass a region
const dm = new DeviceManager('INTERNET_OF_BULBS');
const firestore = admin.firestore();
// start cloud function
exports.configUpdate = functions.firestore
// assumes a document whose ID is the same as the deviceid
.document('device-configs/Iot-device-1')
.onWrite((change,context) =>
var beforeData = change.before.val(); // data before the write
var afterData = change.after.val();
if (context)
await dm.setAuth();
console.log(context.params.deviceId);
// get the new config data
const configData = change.after.data();
return dm.updateConfig(context.params.deviceId, configData);
else
throw(Error("no context from trigger"));
)
Here is the error on my shell when i am trying to deploy,the above code.
firebase deploy
=== Deploying to 'wifi-lights-88783'...
i deploying functions
Running command: npm --prefix "$RESOURCE_DIR" run lint
> functions@ lint /home/suposhmehta/fire/functions
> eslint .
/home/suposhmehta/fire/functions/index.js
17:13 error Parsing error: Unexpected token dm
✖ 1 problem (1 error, 0 warnings)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! functions@ lint: `eslint .`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the functions@ lint 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! /home/suposhmehta/.npm/_logs/2018-11-10T09_38_15_585Z-debug.log
Error: functions predeploy error: Command terminated with non-zero exit code1
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/nvm/versions/node/v8.9.4/bin/node',
1 verbose cli '/usr/local/nvm/versions/node/v8.9.4/bin/npm',
1 verbose cli '--prefix',
1 verbose cli '/home/suposhmehta/fire/functions',
1 verbose cli 'run',
1 verbose cli 'lint' ]
2 info using npm@5.6.0
3 info using node@v8.9.4
4 verbose run-script [ 'prelint', 'lint', 'postlint' ]
5 info lifecycle functions@~prelint: functions@
6 info lifecycle functions@~lint: functions@
7 verbose lifecycle functions@~lint: unsafe-perm in lifecycle true
8 verbose lifecycle functions@~lint: PATH: /usr/local/nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/suposhmehta/fire/functions/node_
modules/.bin:/home/suposhmehta/gopath/bin:/google/gopath/bin:/google/google-cloud-sdk/bin:/usr/local/go/bin:/opt/gradle/bin:/opt/maven/bin:/usr/local/sbin:/usr/local/bin:/usr/sbi
n:/usr/bin:/sbin:/bin:/usr/local/nvm/versions/node/v8.9.4/bin:/google/go_appengine:/google/google_appengine
9 verbose lifecycle functions@~lint: CWD: /home/suposhmehta/fire/functions
10 silly lifecycle functions@~lint: Args: [ '-c', 'eslint .' ]
11 silly lifecycle functions@~lint: Returned: code: 1 signal: null
12 info lifecycle functions@~lint: Failed to exec lint script
13 verbose stack Error: functions@ lint: `eslint .`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (/usr/local/nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:285: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> (/usr/local/nvm/versions/node/v8.9.4/lib/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:925:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
14 verbose pkgid functions@
15 verbose cwd /home/suposhmehta/fire
16 verbose Linux 4.14.33+
17 verbose argv "/usr/local/nvm/versions/node/v8.9.4/bin/node" "/usr/local/nvm/versions/node/v8.9.4/bin/npm" "--prefix" "/home/suposhmehta/fire/functions" "run" "lint"
18 verbose node v8.9.4
19 verbose npm v5.6.0
20 error code ELIFECYCLE
21 error errno 1
22 error functions@ lint: `eslint .`
22 error Exit status 1
23 error Failed at the functions@ lint script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
How do i get rid of these issues?
Please Help.
import * as admin from "firebase-admin";
import * as functions from 'firebase-functions';
import runInDebugContext from 'vm';
import DeviceManager from './devices';
how do i import DeviceManager from './devices';
import * as admin from "firebase-admin";
import * as functions from 'firebase-functions';
import runInDebugContext from 'vm';
import DeviceManager from './devices';
how do i import DeviceManager from './devices';
const admin =require('firebase-admin');
const functions =require('firebase-functions');
admin.initializeApp();
// create a device manager instance with a registry id, optionally pass a region
const dm = new DeviceManager('INTERNET_OF_BULBS');
const firestore = admin.firestore();
// start cloud function
exports.configUpdate = functions.firestore
// assumes a document whose ID is the same as the deviceid
.document('device-configs/Iot-device-1')
.onWrite((change,context) =>
var beforeData = change.before.val(); // data before the write
var afterData = change.after.val();
if (context)
await dm.setAuth();
console.log(context.params.deviceId);
// get the new config data
const configData = change.after.data();
return dm.updateConfig(context.params.deviceId, configData);
else
throw(Error("no context from trigger"));
)
const admin =require('firebase-admin');
const functions =require('firebase-functions');
admin.initializeApp();
// create a device manager instance with a registry id, optionally pass a region
const dm = new DeviceManager('INTERNET_OF_BULBS');
const firestore = admin.firestore();
// start cloud function
exports.configUpdate = functions.firestore
// assumes a document whose ID is the same as the deviceid
.document('device-configs/Iot-device-1')
.onWrite((change,context) =>
var beforeData = change.before.val(); // data before the write
var afterData = change.after.val();
if (context)
await dm.setAuth();
console.log(context.params.deviceId);
// get the new config data
const configData = change.after.data();
return dm.updateConfig(context.params.deviceId, configData);
else
throw(Error("no context from trigger"));
)
firebase deploy
=== Deploying to 'wifi-lights-88783'...
i deploying functions
Running command: npm --prefix "$RESOURCE_DIR" run lint
> functions@ lint /home/suposhmehta/fire/functions
> eslint .
/home/suposhmehta/fire/functions/index.js
17:13 error Parsing error: Unexpected token dm
✖ 1 problem (1 error, 0 warnings)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! functions@ lint: `eslint .`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the functions@ lint 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! /home/suposhmehta/.npm/_logs/2018-11-10T09_38_15_585Z-debug.log
Error: functions predeploy error: Command terminated with non-zero exit code1
firebase deploy
=== Deploying to 'wifi-lights-88783'...
i deploying functions
Running command: npm --prefix "$RESOURCE_DIR" run lint
> functions@ lint /home/suposhmehta/fire/functions
> eslint .
/home/suposhmehta/fire/functions/index.js
17:13 error Parsing error: Unexpected token dm
✖ 1 problem (1 error, 0 warnings)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! functions@ lint: `eslint .`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the functions@ lint 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! /home/suposhmehta/.npm/_logs/2018-11-10T09_38_15_585Z-debug.log
Error: functions predeploy error: Command terminated with non-zero exit code1
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/nvm/versions/node/v8.9.4/bin/node',
1 verbose cli '/usr/local/nvm/versions/node/v8.9.4/bin/npm',
1 verbose cli '--prefix',
1 verbose cli '/home/suposhmehta/fire/functions',
1 verbose cli 'run',
1 verbose cli 'lint' ]
2 info using npm@5.6.0
3 info using node@v8.9.4
4 verbose run-script [ 'prelint', 'lint', 'postlint' ]
5 info lifecycle functions@~prelint: functions@
6 info lifecycle functions@~lint: functions@
7 verbose lifecycle functions@~lint: unsafe-perm in lifecycle true
8 verbose lifecycle functions@~lint: PATH: /usr/local/nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/suposhmehta/fire/functions/node_
modules/.bin:/home/suposhmehta/gopath/bin:/google/gopath/bin:/google/google-cloud-sdk/bin:/usr/local/go/bin:/opt/gradle/bin:/opt/maven/bin:/usr/local/sbin:/usr/local/bin:/usr/sbi
n:/usr/bin:/sbin:/bin:/usr/local/nvm/versions/node/v8.9.4/bin:/google/go_appengine:/google/google_appengine
9 verbose lifecycle functions@~lint: CWD: /home/suposhmehta/fire/functions
10 silly lifecycle functions@~lint: Args: [ '-c', 'eslint .' ]
11 silly lifecycle functions@~lint: Returned: code: 1 signal: null
12 info lifecycle functions@~lint: Failed to exec lint script
13 verbose stack Error: functions@ lint: `eslint .`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (/usr/local/nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:285: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> (/usr/local/nvm/versions/node/v8.9.4/lib/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:925:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
14 verbose pkgid functions@
15 verbose cwd /home/suposhmehta/fire
16 verbose Linux 4.14.33+
17 verbose argv "/usr/local/nvm/versions/node/v8.9.4/bin/node" "/usr/local/nvm/versions/node/v8.9.4/bin/npm" "--prefix" "/home/suposhmehta/fire/functions" "run" "lint"
18 verbose node v8.9.4
19 verbose npm v5.6.0
20 error code ELIFECYCLE
21 error errno 1
22 error functions@ lint: `eslint .`
22 error Exit status 1
23 error Failed at the functions@ lint script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/nvm/versions/node/v8.9.4/bin/node',
1 verbose cli '/usr/local/nvm/versions/node/v8.9.4/bin/npm',
1 verbose cli '--prefix',
1 verbose cli '/home/suposhmehta/fire/functions',
1 verbose cli 'run',
1 verbose cli 'lint' ]
2 info using npm@5.6.0
3 info using node@v8.9.4
4 verbose run-script [ 'prelint', 'lint', 'postlint' ]
5 info lifecycle functions@~prelint: functions@
6 info lifecycle functions@~lint: functions@
7 verbose lifecycle functions@~lint: unsafe-perm in lifecycle true
8 verbose lifecycle functions@~lint: PATH: /usr/local/nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/suposhmehta/fire/functions/node_
modules/.bin:/home/suposhmehta/gopath/bin:/google/gopath/bin:/google/google-cloud-sdk/bin:/usr/local/go/bin:/opt/gradle/bin:/opt/maven/bin:/usr/local/sbin:/usr/local/bin:/usr/sbi
n:/usr/bin:/sbin:/bin:/usr/local/nvm/versions/node/v8.9.4/bin:/google/go_appengine:/google/google_appengine
9 verbose lifecycle functions@~lint: CWD: /home/suposhmehta/fire/functions
10 silly lifecycle functions@~lint: Args: [ '-c', 'eslint .' ]
11 silly lifecycle functions@~lint: Returned: code: 1 signal: null
12 info lifecycle functions@~lint: Failed to exec lint script
13 verbose stack Error: functions@ lint: `eslint .`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (/usr/local/nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:285: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> (/usr/local/nvm/versions/node/v8.9.4/lib/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:925:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
14 verbose pkgid functions@
15 verbose cwd /home/suposhmehta/fire
16 verbose Linux 4.14.33+
17 verbose argv "/usr/local/nvm/versions/node/v8.9.4/bin/node" "/usr/local/nvm/versions/node/v8.9.4/bin/npm" "--prefix" "/home/suposhmehta/fire/functions" "run" "lint"
18 verbose node v8.9.4
19 verbose npm v5.6.0
20 error code ELIFECYCLE
21 error errno 1
22 error functions@ lint: `eslint .`
22 error Exit status 1
23 error Failed at the functions@ lint script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
node.js firebase firebase-authentication google-cloud-functions google-cloud-iot
node.js firebase firebase-authentication google-cloud-functions google-cloud-iot
asked Nov 10 at 10:05
suposh mehta
1
1
I am doing all of this in google cloud shell.
– suposh mehta
Nov 10 at 10:07
Google's tutorial link cloud.google.com/community/tutorials/cloud-iot-firestore-config
– suposh mehta
Nov 13 at 7:45
add a comment |
I am doing all of this in google cloud shell.
– suposh mehta
Nov 10 at 10:07
Google's tutorial link cloud.google.com/community/tutorials/cloud-iot-firestore-config
– suposh mehta
Nov 13 at 7:45
I am doing all of this in google cloud shell.
– suposh mehta
Nov 10 at 10:07
I am doing all of this in google cloud shell.
– suposh mehta
Nov 10 at 10:07
Google's tutorial link cloud.google.com/community/tutorials/cloud-iot-firestore-config
– suposh mehta
Nov 13 at 7:45
Google's tutorial link cloud.google.com/community/tutorials/cloud-iot-firestore-config
– suposh mehta
Nov 13 at 7:45
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53237883%2fgoogle-firebase-functions-to-iot-device-send-config%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I am doing all of this in google cloud shell.
– suposh mehta
Nov 10 at 10:07
Google's tutorial link cloud.google.com/community/tutorials/cloud-iot-firestore-config
– suposh mehta
Nov 13 at 7:45