0

I am trying to run 'node server.js' to connect my raspberry pi device to Azure via the Azure IoT Hub. When I run the command 'node server.js', I receive the following error. Please note that I replaced my computer's user name with 'username'. The file connection_string.js does not have my computer's username in it, despite the error saying that it does. Please see error below:

SyntaxError: Invalid flags supplied to RegExp constructor '*username*'
    at new RegExp (native)
    at Object.<anonymous> (/Users/*username*/iot-hub-c-raspberrypi-getstartedkit/command_center_node/node_modules/azure-iot-common/lib/connection_string.js:9:31)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/Users/*username*/iot-hub-c-raspberrypi-getstartedkit/command_center_node/node_modules/azure-iot-common/common.js:15:21)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/Users/*username*/iot-hub-c-raspberrypi-getstartedkit/command_center_node/server.js:7:15)

Thank you in advance for your help!

  • `/Users/*username*/` I think that is being interpreted as a regex. Did you set the path as a regex instead of a string somewhere? A regex literal is `/regex/` while a string must be surrounded by quotes `"/not/regex/"` – VLAZ Sep 20 '16 at 23:24
  • I do not believe I manually set the path into any files. I feel like it is pulling the path in one of its processes, as I did not type it in anywhere. – Karl Lashkari Sep 21 '16 at 01:55
  • It looks like that there is something wrong with your connection string. Could you provide your code snippet about your connection string, also please replace sensitive information. – Gary Liu Sep 21 '16 at 02:37

1 Answers1

0

Not sure if it is your case or not, but I had similar issue:

SyntaxError: Invalid flags supplied to RegExp constructor 'u'

I fixed it simply by updating Node.js. Previous version was:

$ node -v
v5.1.1

Then I did:

$ curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
   ... long output
$ sudo apt-get install -y nodejs
   ... shorter output
$ node -v
v6.7.0

And no more issues.

Green
  • 28,742
  • 61
  • 158
  • 247