srcbookdev / srcbook

TypeScript-centric app development platform
https://srcbook.com
Apache License 2.0
2.53k stars 97 forks source link

Unhandled 'error' event #314

Open Horadrim opened 1 month ago

Horadrim commented 1 month ago

Steps to reproduce:

  1. Globally install srcbook with npm
  2. Start the application
  3. Click "Create Srcbook"
  4. Upon writing a new title or pasting / writing any code, the application crashes.

Console output:

` Srcbook
Serving static files (React app)... Creating WebSocket server... Initialization complete srcbook@0.0.6 running at http://localhost:2150 node:events:497 throw er; // Unhandled 'error' event ^

Error: spawn npx ENOENT at ChildProcess._handle.onexit (node:internal/child_process:286:19) at onErrorNT (node:internal/child_process:484:16) at process.processTicksAndRejections (node:internal/process/task_queues:82:21) Emitted 'error' event on ChildProcess instance at: at ChildProcess._handle.onexit (node:internal/child_process:292:12) at onErrorNT (node:internal/child_process:484:16) at process.processTicksAndRejections (node:internal/process/task_queues:82:21) { errno: -4058, code: 'ENOENT', syscall: 'spawn npx', path: 'npx', spawnargs: [ 'tsserver' ] }

Node.js v20.16.0 `

benjreinhart commented 1 month ago

Hmm, I cannot seem to reproduce. I'm on mac, using chrome, deleted all my srcbook files (so, clean slate) and then ran:

npm i -g srcbook
srcbook start

This installed and booted srcbook@0.0.6.

I created a srcbook, entered a title, no crash. Then I tried writing code (without installing deps), no crash.

Sanjoy-droid commented 1 month ago

@Horadrim Hmm, me to, I am on Ubuntu, using brave, working fine, not able to reproduce this issue

Cam-Bread commented 1 month ago

I am getting the same error on Windows. I dug into it a bit and found its because of the difference in how windows handles the spawn call. it looks like it needs the option "shell" set to true for windows to be able to run tsserver:

 const child = spawn('npx', ['tsserver'], {
        cwd: options.cwd,
        shell: process.platform == 'win32',
 });

unfortunately it seems like there may still be other issues as am still unable to successfully run typescript cell code even after that change. But hopefully this gives you all a good starting point to supporting windows as well if you decide to do so :)

Horadrim commented 1 month ago

I forgot to mention that I'm using windows 11. I guess since the other guys can't reproduce it on Linux and Mac, seems to be a Windows only issue indeed.

versecafe commented 1 month ago

@Cam-Bread Windows TS code is under the work it's just some extra work with windows white spacing in validators and a few places left not using path.join()

nelslar42 commented 4 days ago

has this been resolved? im having the same issues on Windows

npx srcbook@latest start Srcbook
Serving static files (React app)... Creating WebSocket server... Initialization complete srcbook@0.0.14 running at http://localhost:2150 Error: spawn npm ENOENT at ChildProcess._handle.onexit (node:internal/child_process:286:19) at onErrorNT (node:internal/child_process:484:16) at process.processTicksAndRejections (node:internal/process/task_queues:82:21) { errno: -4058, code: 'ENOENT', syscall: 'spawn npm', path: 'npm', spawnargs: [ 'install', '--include=dev' ] } node:internal/process/promises:391 triggerUncaughtException(err, true / fromPromise /); ^

nichochar commented 4 days ago

Unfortunately windows support is not ready yet. We're working hard to ship a hosted version right now which will make Srcbook usable online making these platform issues less of a pain.