vercel / hyper

A terminal built on web technologies
https://hyper.is
MIT License
42.95k stars 3.47k forks source link

Loading a Plugin locally, fail to import dependencies with "require" #7913

Open ndesgranges opened 2 months ago

ndesgranges commented 2 months ago

Issue

context

I'm trying to improve a plugin (hyper-day-night-switch). To do so, I :

The problem

✅ The plugin, loads properly if I use the npmjs version (original, adding hyper-day-night-switch into plugins). 🔴 But won't load locally (using the forked sources, adding hyper-day-night-switch into localPlugins.

The devtools won't output anything. Though, I could get what's happening running hyper -v :

Plugin error while loading "hyper-auto-dark-mode" (/Users/<me>/.hyper_plugins/local/hyper-auto-dark-mode): Cannot find module 'hyper-one-light'
Require stack:
- /Users/<me>/Documents/Projets/hyper-auto-dark-mode/index.js
- /Applications/Hyper.app/Contents/Resources/app.asar/plugins.js
- /Applications/Hyper.app/Contents/Resources/app.asar/index.js
- 

The require is triggered by this line :

const light = require("hyper-one-light");

I tried adding those modules in plugins so I know it's there : did not work. Also tried an npm install in ~/hyper_plugins, I can see the dependencies going into modules but, still the same issue.

NOTE

I'm not using the dev version cause on MAC I'm getting the following error, with all npm versions I tried, even though I'm not behind a proxy and I can ping the address.

EDIT : I now am, see https://github.com/vercel/hyper/issues/7913#issuecomment-2080448917

RequestError: connect EBADF 140.82.121.4:443
   at ClientRequest.<anonymous> (/Users/<me>/.hyper_plugins/hyper-dev/hyper/node_modules/@electron/get/node_modules got/dist/source/core/index.js:970:111)
    at Object.onceWrapper (node:events:632:26)
    at ClientRequest.emit (node:events:529:35)
    at origin.emit (/Users/<me>/.hyper_plugins/hyper-dev/hyper/node_modules/@electron/get/node_modules/@szmarczak/http-timer/dist/source/index.js:39:20)
    at TLSSocket.socketErrorListener (node:_http_client:501:9)
    at TLSSocket.emit (node:events:517:28)
    at emitErrorNT (node:internal/streams/destroy:151:8)
    at emitErrorCloseNT (node:internal/streams/destroy:116:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1555:16) {
  code: 'EBADF',
ndesgranges commented 2 months ago

So I managed to build hyper in dev mode on Mac OS

For anyone having the issue described in section NOTE, for me it was LuLu messing with npm, had to disable it to build