DEV Community

Cover image for Automating with Nodejs Part - 1 (Setup)
Abhishek Kale
Abhishek Kale

Posted on

1 2

Automating with Nodejs Part - 1 (Setup)

Table of Content

  1. Initializing
  2. writing the script
  3. Install globally(on your system😜)

Description - setting up the environment to write scripts to automate tasks with nodejs and publishing to npm
part I - setup , hello world , testing locally

Initializing

prerequisites

  • nodejs
  • npm

create a folder for your project

cd to the folder -> do npm init

mkdir npm_script
cd ./npm_script
npm init -y
Enter fullscreen mode Exit fullscreen mode

writing the script

create an index.js file(starting point of your script)

adding the hashbang!

#!/usr/bin/env node

it specifies the the environment the script will run on

without hashbang

node ./filename.js
Enter fullscreen mode Exit fullscreen mode

with hashbang

./filename.js
Enter fullscreen mode Exit fullscreen mode

at this point your files would look like this
added hashbang

we would add some code to test our script

const myAwesomeFunction = () => {
 console.log("Hello World")
}
Enter fullscreen mode Exit fullscreen mode

which would look like
added hello world

now we can test if our code runs
by just typing
./index.js

installing the script globally

npm install -g  // in your script directory
Enter fullscreen mode Exit fullscreen mode

now you can access the script anywhere on your system

*to be continued (writing script to organize files, publishing to npm)

Postgres on Neon - Get the Free Plan

No credit card required. The database you love, on a serverless platform designed to help you build faster.

Get Postgres on Neon

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more