question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: Cannot find module 'debug'

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
Interlopingcommented, Feb 6, 2019

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 circular-json@0.3.3: CircularJSON is in maintenance only, flatted is its successor.
npm WARN tuya-helper@1.0.0 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

1reaction
bartekd123commented, Feb 1, 2019

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Hi, I get this bug here Error: Cannot find module 'debug'
It could be an issue with your local node_modules directory. I would recommend deleting and re-installing it fresh. Then check your local ...
Read more >
Cannot find module 'debug' · Issue #876 · koajs/koa - GitHub
I'm getting this error: Error: Cannot find module 'debug' at Function.Module._resolveFilename (module.js:325:15) at Function.Module.
Read more >
Node.js debug doesn't work with Error: Cannot find module at ...
Hi, This worked prior 2016.2. Create a debug configuration for Node.js > add working directory value. Debug won't work with Error: Cannot find...
Read more >
Error NPM global install cannot find module - Edureka
Hello @kartik,. I got this error Error: Cannot find module 'number-is-nan' whereas the module actually exists. It was due to a bad/ ...
Read more >
How to debug a node issue that only occurs in 1 of 3 ...
The error I get (only on Azure) is: An unhandled exception occurred while processing the request. InvocationException: Cannot find module ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found