OpenWonderLabs / homebridge-switchbot

The Homebridge SwitchBot plugin allows you to access your SwitchBot Device(s) from HomeKit. Homebridge.
https://openwonderlabs.github.io/homebridge-switchbot/
ISC License
241 stars 51 forks source link

Plugin update error #999

Closed PaulPizzey247 closed 3 weeks ago

PaulPizzey247 commented 1 month ago

Describe the Bug

I'm getting this error when updating the plugin through the Homebridge-Config-UI-X plugin screen. I also get it when trying to uninstall the plugin.

This is the only plugin i get the error for. All the others install/uninstall as expected.

npm error code ENOTEMPTY npm error syscall rename npm error path /var/lib/homebridge/node_modules/@switchbot/homebridge-switchbot npm error dest /var/lib/homebridge/node_modules/@switchbot/.homebridge-switchbot-cCp4HJsc npm error errno -39 npm error ENOTEMPTY: directory not empty, rename '/var/lib/homebridge/node_modules/@switchbot/homebridge-switchbot' -> '/var/lib/homebridge/node_modules/@switchbot/.homebridge-switchbot-cCp4HJsc'

To Reproduce

Update plugin

Expected Behavior

Plugin updates

Relevant Log Output

USER: pi
DIR: /var/lib/homebridge
CMD: npm install --save @switchbot/homebridge-switchbot@3.6.0
⠙
⠹
⠸
⠼
⠴
⠦
⠧
⠇
⠏
⠋
⠙
⠹
⠸
⠼
⠴
⠦
⠧
⠇
⠏
⠋
⠙
⠹
⠸
⠼
⠴
npm error code ENOTEMPTY
⠴
npm error syscall rename
⠴
npm error path /var/lib/homebridge/node_modules/@switchbot/homebridge-switchbot
⠴
npm error dest /var/lib/homebridge/node_modules/@switchbot/.homebridge-switchbot-cCp4HJsc
⠴
npm error errno -39
⠴
npm error ENOTEMPTY: directory not empty, rename '/var/lib/homebridge/node_modules/@switchbot/homebridge-switchbot' -> '/var/lib/homebridge/node_modules/@switchbot/.homebridge-switchbot-cCp4HJsc'
⠴

⠴
npm error A complete log of this run can be found in: /home/pi/.npm/_logs/2024-07-07T05_57_16_255Z-debug-0.log
⠴

Operation failed with code 217.

You can download this log file for future reference.

See https://github.com/homebridge/homebridge-config-ui-x/wiki/Troubleshooting for help.

Config for homebridge-switchbot

{
    "name": "SwitchBot",
    "credentials": {
        "token": "TOKEN",
        "secret": "99f86d73a8c2a6e7402e60a6217874ae",
        "notice": "Keep your Token & Secret a secret!"
    },
    "options": {
        "devices": [
            {
                "deviceId": "EC6D55CDE3C7",
                "configDeviceName": "HOME-PC",
                "configDeviceType": "Bot",
                "connectionType": "OpenAPI",
                "scanDuration": 1,
                "bot": {
                    "mode": "press",
                    "deviceType": "switch",
                    "allowPush": true,
                    "doublePress": 1
                },
                "maxRetry": 25,
                "refreshRate": 360,
                "offline": false,
                "external": false
            }
        ],
        "refreshRate": 360
    },
    "_bridge": {
        "username": "0E:08:72:D9:D4:44",
        "port": 48515
    },
    "platform": "SwitchBot"
}

Screenshots

image

Device and Model

Homebridge Raspberry Pi 4

Node.js Version

20.15.0

NPM Version

10.7.0

Homebridge Version

1.8.3

Homebridge Switchbot Plugin Version

3.6.0

Homebridge Config UI X Plugin Version

4.56.4

Operating System

Homebridge

sptv1 commented 1 month ago

I got the exact same error. Never had that before with any plugin.

donavanbecker commented 1 month ago

You will need to run

rm -R /var/lib/homebridge/node_modules/@switchbot/.homebridge-switchbot-cCp4HJsc

To clear out that folder

May also need to run

rm -R /var/lib/homebridge/node_modules/@switchbot/.homebridge-switchbot

Then reinstall the plugin.

AKWillows commented 1 month ago

I have also experienced an error when updating from 3.5.0 to 3.6.0

gyp ERR! build error gyp ERR! stack Error: not found: make gyp ERR! stack at getNotFoundError (/volume1/@appstore/homebridge/app/lib/node_modules/npm/node_modules/which/lib/index.js:16:17) gyp ERR! stack at which (/volume1/@appstore/homebridge/app/lib/node_modules/npm/node_modules/which/lib/index.js:77:9) gyp ERR! stack at async doWhich (/volume1/@appstore/homebridge/app/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:112:22) gyp ERR! stack at async loadConfigGypi (/volume1/@appstore/homebridge/app/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:77:7) gyp ERR! stack at async build (/volume1/@appstore/homebridge/app/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:35:3) gyp ERR! stack at async run (/volume1/@appstore/homebridge/app/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js:81:18) gyp ERR! System Linux 4.4.302+ gyp ERR! command "/volume1/@appstore/Node.js_v20/usr/local/bin/node" "/volume1/@appstore/homebridge/app/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" gyp ERR! cwd /volume1/homebridge/node_modules/@switchbot/homebridge-switchbot/node_modules/@stoprocent/bluetooth-hci-socket gyp ERR! node -v v20.9.0 gyp ERR! node-gyp -v v10.0.1 gyp ERR! not ok npm ERR! code 1 npm ERR! path /volume1/homebridge/node_modules/@switchbot/homebridge-switchbot/node_modules/@stoprocent/bluetooth-hci-socket npm ERR! command failed npm ERR! command sh -c node-gyp-build

npm ERR! A complete log of this run can be found in: /var/packages/homebridge/home/.npm/_logs/2024-07-07T16_52_27_947Z-debug-0.log Failed to rebuild. Restoring previous version... Restore Complete. Installation failed.

AKWillows commented 1 month ago

Tried deleting and reinstalling but the get this error:

[7/7/2024, 5:58:50 PM] ERROR LOADING PLUGIN @switchbot/homebridge-switchbot: [7/7/2024, 5:58:50 PM] Error: Cannot find package 'node-switchbot' imported from /volume1/homebridge/node_modules/@switchbot/homebridge-switchbot/dist/platform.js at new NodeError (node:internal/errors:406:5) at packageResolve (node:internal/modules/esm/resolve:789:9) at moduleResolve (node:internal/modules/esm/resolve:838:20) at defaultResolve (node:internal/modules/esm/resolve:1043:11) at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:383:12) at ModuleLoader.resolve (node:internal/modules/esm/loader:352:25) at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:228:38) at ModuleWrap. (node:internal/modules/esm/module_job:85:39) at link (node:internal/modules/esm/module_job:84:36)

donavanbecker commented 1 month ago

Can you try the latest beta:

npm version

Click here to find out how to install Beta

github-actions[bot] commented 1 month ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] commented 3 weeks ago

This issue has been closed as no further activity has occurred.

fancypantsifier commented 4 days ago

I'm stuck on the cannot find error node-switchbot error as well:

[8/24/2024, 9:37:02 PM] ====================
[8/24/2024, 9:37:02 PM] ERROR LOADING PLUGIN @switchbot/homebridge-switchbot:
[8/24/2024, 9:37:02 PM] Error: Cannot find package 'node-switchbot' imported from /volume2/homebridge/node_modules/@switchbot/homebridge-switchbot/dist/platform.js
    at new NodeError (node:internal/errors:406:5)
    at packageResolve (node:internal/modules/esm/resolve:789:9)
    at moduleResolve (node:internal/modules/esm/resolve:838:20)
    at defaultResolve (node:internal/modules/esm/resolve:1043:11)
    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:383:12)
    at ModuleLoader.resolve (node:internal/modules/esm/loader:352:25)
    at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:228:38)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:85:39)
    at link (node:internal/modules/esm/module_job:84:36)

I've tried versions 3.5.0 through the current 3.7.1-beta.11. I see errors about not being able to find make during install, which I've also seen reported in other Issues. I'm running on a Synology NAS with the latest Homebridge and Node v20.9.0. Everything was fine until I tried to update to a new version of the plugin, but now I cannot seem to get back to a good state.