Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the node.js analog of python -i: run and enter interactive mode?

Tags:

node.js

In python there is a nice feature, python -i. For example, python -i myprogram.py will run the program and then enter the interactive mode, as if I have pasted the entire program into the interactive shell.

Is there a similar command in node.js?

like image 323
Sergey Orshanskiy Avatar asked Jun 08 '14 21:06

Sergey Orshanskiy


People also ask

What is Node JS for Python?

Comparing NodeJS vs Python, Node. js is an open-source JS framework used to build both client and server-side network apps, while Python is an object-oriented, high-level programming language. NodeJS has a reputation for creating scalable and high-performance apps with its rich tech stack and robust ecosystem.

Can you use node js with Python?

js and Python finding out that Node. js is awesome for Web Development and Python for Data Sciences. Actually, we don't need to always stick with the same programming language as there are ways to use them both together. In this article, I will show you an example of how to use a Python script from the Node.

Which is better Python or node JS?

Python is a better option for web development, financial technology, and machine learning. Whereas NodeJS is a better choice for developing IoT-based apps, online chat apps, video streaming sites, single-page apps, and other I/O-intensive web applications and web apps.

What type of programming language is used by node JS and what can it do?

Node. js is an open source cross-platform runtime environment written in JavaScript. It is built on Chrome's V8 JavaScript engine, which parses and executes the JavaScript code. Node uses an event-driven, non-blocking I/O model, which makes it fast and lightweight.


1 Answers

Docs at https://nodejs.org/api/cli.html

-r, --require module

Preload the specified module at startup.

Follows require()'s module resolution rules. module may be either a path to a file, or a node module name.

node -i -r ./myprogram.js

-e, --eval "script"

Evaluate the following argument as JavaScript. The modules which are predefined in the REPL can also be used in script.

node -i -e "console.log('A message')"

These features have been added since the previous response in 2014 with the following pull requests.

  • https://github.com/nodejs/node/pull/2253
  • https://github.com/nodejs/node/pull/5655
like image 93
here Avatar answered Oct 23 '22 02:10

here