konsumer / tplink-lightbulb

Control TP-Link smart lightbulbs from nodejs
MIT License
190 stars 32 forks source link

Unable run "Cannot find module tplink-lightbulb.cjs" #62

Closed aciccarello closed 3 years ago

aciccarello commented 3 years ago

I tried running the scan command via npx but it failed. It seems like there's only one javascript file in the npm release.

➜  ~ npx tplink-lightbulb scan
node:internal/modules/cjs/loader:936
  throw err;
  ^

Error: Cannot find module '../dist/tplink-lightbulb.cjs'
Require stack:
- /Users/aciccarello/.npm/_npx/ffb32e4996656d29/node_modules/tplink-lightbulb/src/tplight.cjs
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:94:18)
    at Object.<anonymous> (/Users/aciccarello/.npm/_npx/ffb32e4996656d29/node_modules/tplink-lightbulb/src/tplight.cjs:3:24)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:79:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/aciccarello/.npm/_npx/ffb32e4996656d29/node_modules/tplink-lightbulb/src/tplight.cjs'
  ]
}
➜  ~ node -v 
v16.8.0
➜  project-name ls -R node_modules/tplink-lightbulb
LICENSE      README.md    package.json src

node_modules/tplink-lightbulb/src:
tplight.cjs
konsumer commented 3 years ago

Not sure what happened, but I noticed same thing. I re-published after build and it still didn't include them. I removed ./ from files paths in package, and publlished again, and it seems to have fixed it in tplink-lightbulb@1.7.4:

npx tplink-lightbulb@1.7.4

Usage: tplight <COMMAND>

Commands:
  tplight scan                              Scan for lightbulbs
  tplight on <ip>                           Turn on lightbulb
  tplight off <ip>                          Turn off lightbulb
  tplight bright <ip> <brightness>          Set the brightness of the lightbulb
                                            (for those that support it)
  tplight temp <ip> <color>                 Set the color-temperature of the
                                            lightbulb (for those that support
                                            it)
  tplight hex <ip> <color>                  Set color of lightbulb using hex
                                            color (for those that support it)
  tplight hsb <ip> <hue> <saturation>       Set color of lightbulb using HSB
  <brightness>                              color (for those that support it)
  tplight cloud <ip>                        Get cloud info
  tplight raw <ip> [json]                   Send a raw JSON command, use param
                                            or stdin
  tplight details <ip>                      Get details about the device
  tplight led <ip> <ledState>               Turn on/off LED indicator
  tplight wifi <ip>                         List available wifi for a particular
                                            device
  tplight join <ip> <SSID> [SECRET]         Configure the device to use these
                                            wifi settings

Options:
  -h, --help     Show help                                             [boolean]
      --version  Show version number                                   [boolean]

Examples:
  tplight scan -h     Get more detailed help with `scan` command
  tplight on -h       Get more detailed help with `on` command
  tplight off -h      Get more detailed help with `off` command
  tplight temp -h     Get more detailed help with `temp` command
  tplight hex -h      Get more detailed help with `hex` command
  tplight hsb -h      Get more detailed help with `hsb` command
  tplight cloud -h    Get more detailed help with `cloud` command
  tplight raw -h      Get more detailed help with `raw` command
  tplight details -h  Get more detailed help with `details` command
  tplight led -h      Get more detailed help with `led` command
  tplight wifi -h     Get more detailed help with `wifi` command
  tplight join -h     Get more detailed help with `join` command

Closing for now, but feel free to add more comments if you still have issues.

aciccarello commented 3 years ago

Thanks for the quick response! I've confirmed this fixed the issue.