fh1ch/node-bacstack

REFERENCE ERROR: require is not defined

alejandroflamerich opened this issue · 0 comments

Node Version: 6.14.10

Node BACstack Version: 0.0.1-beta.13

Im new in BACnet protocol

Im doing the first bacnet protocol in android. IM using cordova as a tool.
Make the step as this repository sais.

1.- npm install --save bacstack (it was installed in /node_modules/bacstack folder)
2.- I added this code beloow to my index.html page.
3.- Run the app and press my button ".bacnetButton" and get the error -> require is not defined

`

> <body>
> 
> </body>
> 
> <script type="text/javascript">
>        app.initialize();
> 
> $( document ).ready(function() {
> 	$( ".bacnetButton" ).on( "click", function() {
> 	     bac();
> 	});
> });
> 
> function bac(){
> try{
>             const bacnet = require('bacstack');
>             
>             // Initialize BACStack
>             const client = new bacnet({apduTimeout: 6000});
>             
>             // Discover Devices
>             client.on('iAm', (device) => {
>               console.log('address: ', device.address);
>               console.log('deviceId: ', device.deviceId);
>               console.log('maxApdu: ', device.maxApdu);
>               console.log('segmentation: ', device.segmentation);
>               console.log('vendorId: ', device.vendorId);
>             });
>             client.whoIs();
>             
>             // Read Device Object
>             const requestArray = [{
>               objectId: {type: 8, instance: 4194303},
>               properties: [{id: 8}]
>             }];
>             client.readPropertyMultiple('192.168.1.43', requestArray, (err, value) => {
>               console.log('value: ', value);
>             });
> }catch(e){
>    console.log('error: BAC ' + e);
> }   	
> }		
> </script>

`