I’m making a project in Node.js and I’d like a way to manually poke behind the scenes and execute commands for testing. I noticed that there is a console in Glitch, but it appears to be for something different since it wouldn’t accept Javascript commands and didn’t work with process.openStdin().
Is there any way to access a javascript console through Glitch?
The console starts with a linux bash shell, with the $ prompt. You can run node in there by typing node and any parameters you want, then it will give you the node > prompt.
$ node app.js
events.js:183
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE :::3000
at Server.setupListenHandle [as _listen2] (net.js:1360:14)
at listenInCluster (net.js:1401:12)
at Server.listen (net.js:1485:7)
at Function.listen (/rbd/pnpm-volume/40b69335-86e4-4e74-a149-2557639749bc/node_modules/.registry.npmjs.org/express/4.17.1/node_modules/express/lib/application.js:618:24)
at Object.<anonymous> (/app/app.js:122:5)
at Module._compile (module.js:653:30)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
Seems like that doesn’t work because the app is already running (EADDRINUSE)
Well I’m running a bot, with the idea that it is running 24/7. However, the idea is that if need be I can tinker from the back end without having to restart it. I’m sorry if that wasn’t clear.
Unfortunately, neither of those options work for me due to what I said previously. I guess I’m going to have to do it through a third party, i.e. Discord PMs from a specific user leading to eval().
Another way might be to conditionally redirect requests through an interactive proxy, using an internal port. It would require signalling the server script to let it know when to use the proxy, and a decently short timeout if the proxy falls over.