Are there any Node.JS IDE's that are REPL interactive and mainstain state like the node.js console does? - node.js

I'm looking for an IDE or environment, or "graphical console" similar to ISE for PowerShell.
I want to work on some JavaScript but not have a new instance of a node runtime everytime. Just like in the console I want to be able to run some code here and there, and still have access to the variables from commands I ran a few minutes ago. Also i'd love one that also can take the JavaScript Objects or JSON and display them visually rather than just in plain text like the console does.
Is there any IDE for this sort of thing, or are all the Node environments build for starting a new Node instance everytime you run your solution?

I'm not a Javascript programmer, so I don't know exactly if this is what you are looking for, but you might check out Cloud9 IDE. It's web-based, supports Node.js, and saves the exact state of your setup so you wouldn't need to restart anything every time you log in.

Related

How to debug a serverless framework plugin?

I've searched throughout google about this question and I had no success...
I want to work on a serverless plugin fix, but I don't know how to attach the process to debug the code.
Currently, I'm using vscode and the plugin was developed using nodejs + typescript.
Does anyone have any tip or article explaining how to do that?
As every other process, that you want to debug, you need to run it and somehow connect the debugger to it.
You need to remember, that Serverless Framework is written in JS/TS, so it runs in Node.js. So you can debug it quite easily, if you are developing your Lambdas in Node.js, as it's quite common environment.
How to do it using Jetbrains/Webstorm/IntelliJ
Go to your node_modules directory and find the source code of the plugin, that you want to debug.
In the source code place the breakpoint.
Now Create a new "Run configuration" in IDE for NPM, that should be similar to mine:
4. Make sure you've chosen the correct package.json!
5. Now simply start debugging, like you normally do, but choose the run configuration, that you've just created.
In my example I'm using package script from package.json, but it could be also any other script, that triggers serverless deploy or serverless print in the end.
And that's it! Breakpoints should be triggered normally, like when you debug your own JS code.

Detect if code using NodeJS specific global objects, what may not exist in browser

My code was written in in NodeJS, but It can also work in browser. But I made mistake earlier when I tried read process.versions variable directly.
Is there way write test in NodeJS and test am I using some node specific global objects or variables ?
Test has to fail since process variable is not defined in browser. But when I did search, Google gives me tutorials "How run my tests in browser", but I am not fan of that idea, I would love to stay in NodeJS. I think maybe some wrapper what hides those node specific global variables. Most likely someone has dome something like that, but google wasn't big help.
I am using mocha for testing, but I am open for suggestions.

With IntelliJ 2020 Ultimate how can I run any Javascript file with nodejs?

Is there a way (in IntelliJ Ultimate) to run any javascript file with NodeJS?
I'm basically looking for the Run command to do
cd DIRECTORY-OF-FILE
node SELECTED-FILE
I would like Debug command to also work; And I realize that not every javascript file is formatted to run in nodejs. :-)
I'm looking for functionality that is built-in for Java (to be able to right click and select run or debug a *.java file).
I have a bunch of sample programs and it is a PITA to create a Run/Debug configuration for each simple script.
What have I done
I've searched the internet intellij run JS file in node
and come up with how to run a single file with NodeJS. https://www.jetbrains.com/help/idea/running-and-debugging-node-js.html#debugLocal. This works ok.
I've searched stack overflow https://stackoverflow.com/search?q=%5Bintellij-idea%5D+run+javascript+file+with+nodejs
And come up with
Project type for executing JavaScript in IntelliJ IDEA - This is very similar and if there were an answer, it would likely answer my question.
Use the Run context menu in the JS file (or the corresponding keyboard shortcut):

Vimscript function calls from terminal emulator

I have Language server client (vim-lsc) installed as a plugin in neovim. This client interacts with a language server for couple of languages, like python or R, and provides features like autocomplete, variable renaming etc...
One feature I want to use is the code execution, in which case you can select the part of the code and then send it to the LSP server for evaluation and get the response for it. I can do a similar thing if I create a terminal emulator "term://python" and copy paste the code there, but in this way there are two "servers" running, one via the LSP server and other from the terminal, similar to what vim-matlab does.
I was hoping to be able to do both with just one instance of python or R or MATLAb running. If there is a way to send the typed "command" in the terminal emulator to the LSP server via the vim-lsc plugin, then the job can be done with just one instance running.
I also thought of making a vimscript which creates a buffer that emulates terminal (like how Conque or vim-terminal do) and then capture and pass the commands via that script. Although, I was not able to figure out how those plugin made the prompt and command output non-modifiable but keeping the current typed command by the user modifiable.
My reason for preferring the LSP route and not opting for plugins like vimterm is that they don't provide various features like autocomplete and refactoring.
Any suggestions would be welcome. Thanks.
EDIT: I would like to clarify that as of now I don't think vim-lsc has the capability to send the executeCommand request. I wrote a small vimscript (sepatate code) which is able to do that. I plan to submit a pull-request in time and have the feature available in vim-lsc, hence the inclusion of vim-lsc in the description. Apologies for the confusion.
If it's part of the LSP protocol, and you can indeed send the code to the LSP server for execution, then it's not one that vim-lsc has implemented; I can't find it in the helpfile. Best thing you can do is search on the issue page and/or post about the feature yourself.

linux or windows terminal over the web

I'm planing to make a web app which will allow you to have a Linux Terminal on a web page so that you can execute any command an get the response as if you were in front of your linux terminal.
I planed to use NodeJS as it is server side JavaScript, asynchronous and fast.
Also I saw this wich does exactly what i'm trying to do, I peeked in the source code, but didn't found something useful, I also analysed it with google chrome developer tools on the network tab, but there is absolutely nothing even while executing some commands and getting responses. How is this possible ? what technology do you think they used ?
So I wanted to get your advice, your experience in order to start it the right way.
I firstly decided to use NodeJS, but if there is another programming language or Framework more appropriate for this kind of application please let me know.
If you want a real terminal in the browser using node.js on the backend, you might give tty.js a try.
Alternatively you can use the pty.js module manually which is used by tty.js. Along with that, you could also use xterm for doing the browser-side terminal emulation.

Resources