Tuya-convert: Error: Cannot find module 'debug'

Created on 31 Jan 2019  路  8Comments  路  Source: ct-Open-Source/tuya-convert

I have been trying on a raspberry pi zero (wired usb to rj45 which I use to ssh into it and the wireless for tuya-convert) with the both the lite raspbian and full raspbian, and no matter what I do, it doesn't want to connect.

Looking at the smartconfig log file, I see this

pi@raspberrypi:~/tuya-convert/scripts $ cat smarthack-smartconfig.log 
module.js:559
    throw err;
    ^

Error: Cannot find module 'debug'
    at Function.Module._resolveFilename (module.js:557:15)
    at Function.Module._load (module.js:484:25)
    at Module.require (module.js:606:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/home/pi/tuya-convert/scripts/smartconfig/smartconfig.js:16:15)
    at Module._compile (module.js:662:30)
    at Object.Module._extensions..js (module.js:673:10)
    at Module.load (module.js:575:32)
    at tryModuleLoad (module.js:515:12)
    at Function.Module._load (module.js:507:3)

I used a fresh install of the OS, then ran these commands, before I started with tuya-convert

sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install network-manager
sudo apt install git

Any ideas what I can try to make this work?

Also here is my smarthack web file

pi@raspberrypi:~/tuya-convert/scripts $ cat smarthack-web.log 
^CTraceback (most recent call last):
  File "./fake-registration-server.py", line 132, in <module>
    main()
  File "./fake-registration-server.py", line 128, in main
    tornado.ioloop.IOLoop.current().start()
  File "/usr/local/lib/python3.5/dist-packages/tornado/platform/asyncio.py", line 132, in start
    self.asyncio_loop.run_forever()
  File "/usr/lib/python3.5/asyncio/base_events.py", line 421, in run_forever
    self._run_once()
  File "/usr/lib/python3.5/asyncio/base_events.py", line 1388, in _run_once
    event_list = self._selector.select(timeout)
  File "/usr/lib/python3.5/selectors.py", line 445, in select
    fd_event_list = self._epoll.poll(timeout, max_ev)
KeyboardInterrupt
Listening on port 80

All 8 comments

Did you run ./install_prereq.sh?

Yes, it installed everything in the prereq file. Forgot to mention that.

According to the log you are missing the npm package debug. You could try running npm i inside scripts/smartconfig, might tell you why it won't install or might just work.

Alternatively, you could try the python based version slated to replace the node implementation, at kueblc/tuya-convert. Make sure you're on the smart-link-py branch.

Thank you Colin! I will give it a shot tonight.

I tried npm i, and that didn't work and didn't give any real errors.

pi@raspberrypi:~/tuya-convert/scripts/smartconfig $ npm i
npm WARN deprecated [email protected]: CircularJSON is in maintenance only, flatted is its successor.
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN [email protected] No repository field.

added 500 packages in 336.039s

Then I tried the python branch, and that one doesn't work either, so Im thinking something else is wrong.

This is my entire wifi log file, is the failure to create the wlan an issue? I was able to connect to the wifi using my phone (I replaced the last part of the mac addresses with a's)

pi@raspberrypi:~/tuyapy/tuya-convert/scripts $ cat smarthack-wifi.log 
Backing up NetworkManager.cfg...
Restarting NetworkManager...
Backing up /etc/dnsmasq.conf...
Writing dnsmasq config file...
Creating new /etc/dnsmasq.conf...
Writing hostapd config file...
Configuring AP interface...
Applying iptables rules...
Starting DNSMASQ server...
Starting AP on wlan0 in screen terminal...
Configuration file: /etc/hostapd/hostapd.conf
Failed to create interface mon.wlan0: -95 (Operation not supported)
wlan0: Could not connect to kernel driver
Using interface wlan0 with hwaddr b8:27:eb:aa:aa:aa and ssid "vtrust-flash"
wlan0: interface state UNINITIALIZED->ENABLED
wlan0: AP-ENABLED 
wlan0: STA d4:a3:aa:aa:aa:aa IEEE 802.11: associated
wlan0: AP-STA-CONNECTED d4:a3:3d:aa:aa:aa
wlan0: STA d4:a3:3d:aa:aa:aa RADIUS: starting accounting session 5C538F21-00000000
wlan0: STA d4:a3:3d:aa:aa:aa WPA: pairwise key handshake completed (RSN)

I gave up on my raspberry pi zero w, and used a laptop to flash my switches, so I am good now. Thanks for your help

Glad you were able to figure it out. We'll have to keep an eye on the Raspberry Pi Zero W and see if we can track down the root cause of your issue so others can avoid it moving forward. Thanks for your report.

I was previously having success but for the last few days can't get any sonoff devices to connect to vtrust-flash to start the process. My phone connects to it, but the sonoff devices (bulb, switch) just flash in pairing mode until timing out. I noticed this same "cannot find module 'debug' error so I ran npm -i inside scripts/smartconfig as suggested. That seemed fine except for two warnings:

npm WARN deprecated [email protected]: CircularJSON is in maintenance only, flatted is its successor.
npm WARN [email protected] No repository field.

Running start_flash.sh I now get this:

Backing up /etc/dnsmasq.conf...
Writing dnsmasq config file...
Creating new /etc/dnsmasq.conf...
Writing hostapd config file...
Configuring AP interface...
Applying iptables rules...
Starting DNSMASQ server...
Starting AP on wlp1s0 in screen terminal...
Configuration file: /etc/hostapd/hostapd.conf
Using interface wlp1s0 with hwaddr 00:XX:XX:XX:XX:XX and ssid "vtrust-flash"
wlp1s0: interface state UNINITIALIZED->ENABLED
wlp1s0: AP-ENABLED 
Listening on port 80
1549414909: mosquitto version 1.4.8 (build date Wed, 05 Sep 2018 15:51:27 -0300) starting
1549414909: Using default config.
1549414909: Opening ipv4 listen socket on port 1883.
1549414909: Opening ipv6 listen socket on port 1883.
wlp1s0: STA ac:XX:XX:XX:XX:XX IEEE 802.11: authenticated
wlp1s0: STA ac:XX:XX:XX:XX:XX IEEE 802.11: associated (aid 1)
wlp1s0: AP-STA-CONNECTED ac:XX:XX:XX:XX:XX
wlp1s0: STA ac:XX:XX:XX:XX:XX RADIUS: starting accounting session 5C5A31FA-00000000
wlp1s0: STA ac:XX:XX:XX:XX:XX WPA: pairwise key handshake completed (RSN)
/root/tuya/tuya-convert/scripts/smartconfig/node_modules/debug/src/node.js:132
        let val = process.env[key];
        ^^^

SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:374:25)
    at Object.Module._extensions..js (module.js:417:10)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Module.require (module.js:354:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/root/tuya/tuya-convert/scripts/smartconfig/node_modules/debug/src/index.js:9:19)
    at Module._compile (module.js:410:26)
    at Object.Module._extensions..js (module.js:417:10)

This is on an ubuntu 16.04 server machine.

UPDATE
Success by using the python version mentioned above. To get that to work it was necessary to also do:
apt-get install python3-crypto

Was this page helpful?
0 / 5 - 0 ratings

Related issues

HellfireZA picture HellfireZA  路  10Comments

uav2608 picture uav2608  路  11Comments

prankousky picture prankousky  路  7Comments

Cyber1000 picture Cyber1000  路  9Comments

baldarn picture baldarn  路  4Comments