LinuxCommandLibrary

node

Run JavaScript file

TLDR

Run JavaScript file

$ node [script.js]
copy
Start REPL
$ node
copy
Evaluate expression
$ node -e "[console.log('hello')]"
copy
Run with arguments
$ node [script.js] [arg1] [arg2]
copy
Inspect for debugging
$ node --inspect [script.js]
copy
Check syntax only
$ node --check [script.js]
copy
Print version
$ node --version
copy
Run TypeScript with loader
$ node --loader ts-node/esm [script.ts]
copy

SYNOPSIS

node [options] [script] [arguments]

DESCRIPTION

node is the Node.js JavaScript runtime. It executes JavaScript outside browsers.
The tool provides V8 engine access. Supports npm ecosystem and async I/O.
node runs JavaScript server-side.

PARAMETERS

SCRIPT

JavaScript file to execute.
ARGUMENTS
Arguments passed to script.
-e CODE
Evaluate code string.
--inspect
Enable debugger.
--check
Syntax check only.
--version
Show version.
--help
Display help information.

CAVEATS

V8 engine based. Single-threaded event loop. Requires node installation.

HISTORY

Node.js was created by Ryan Dahl in 2009 to bring JavaScript to server-side development.

SEE ALSO

npm(1), npx(1), deno(1)

Copied to clipboard