Run Node.js scripts from the command line
Introduction
In this short article you will learn how to run a Node.js script file from the command line.
To run a .js
file Node.js must be installed on the system. The basic way to run a Node.js script is to run the node
globally available command and pass the name of the file you want to execute.
If your main Node.js application file is index.js
, you can call it by:
node index.js
Here the node command must be executed in the same directory of the index.js file.
You can pass arguments to index.js
file as well.
node index.js arg1 arg2 arg3
Here arg1
, arg2
and arg3
are the arguments passed to index.js
file
To read passed arguments to scrpt file use following code snippet.
var myArgs = process.argv.slice(2); console.log('myArgs: ', myArgs); // will return myArgs: [ 'one', 'two', 'three', 'four', 'five' ]
#run node.js script #run node.js script in background #running node js scripts in jenkins #run node js script with arguments #run node js script in terminal #run node js script from python #run node js script in browser #run node js script from html #run node js scripts #run node js script online #run node.js script as service #run a node js script #run node js in bash script #batch file run node js script #run node js script from command line #run node js script in cron #run node js script in cmd #run node.js from javascript client side #c# run node.js script #node js run script command #run node.js script as daemon #docker run node js script #node js run script every hour #node js run script every minute #node js run external script #run node js script from php #run node js script forever #run node js from script #execute node js script from php #run node js code in browser #how run node js script #run node js script in html #run node.js in script #execute nodejs script jenkins #java run node.js script #run node js script locally #run node js script linux #node js run multiple scripts #jenkins execute node js script npm install #npm run node js script #run node js script on startup #run node.js script on windows #run node.js on script #run node js file from powershell script #node js run powershell script #node js run script with parameters #node js run package.json script #plesk node js run script #execute node js script #node js run remote script #run r script from node.js #node.js run run script #run node.js from shell script #node js run js script #how to run node js scripts #how to run node js script in browser #how to run node.js script in windows #node.js run test script #how to run node js script in background #run node.js script ubuntu #execute node js script ubuntu #run js script using node #node.js run php scripts via php fpm #run node.js script windows #run node.js with javascript #run js script with node #node js run script with environment variables #node js run python script with arguments #run js file on node
Leave a Comment