Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

189
Views
Invoke a JavaScript or Node.js program using an alias

I am writing a JavaScript program that needs to invoked on the command line using a special command/alias. Instead of typing node fileName.js, I need to be able to just type newFile to run it. My understanding (correct me if I'm wrong) is that I could create a Bash script to run the JavaScript and use an alias to run that. But I would like to avoid using a Bash script if I can.

I looked into Node to see if I can do this. All I found was information about putting the name of the program in the package.json file, as a value for "start", under "scripts." But then to run the program I would have to type npm start. I looked for a way that I could create an alias for npm start within Node itself, but I didn't find one.

Is there a way to do what I want, with or without Node, without using an external script?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

No you can't... It might possible with shell script. But in your machine node js run with help of npm.

Every javascript project has a package.json file which is managed package file for your project. So you can not do what you want.

What I suggest: Use nodemon.

npm i nodemon

then in package.json add another script "dev" or whatever you want or you can write under start script.

"dev":"nodemon app.js",

Then everytime you save your application your server will restart automatically

Note: Each time you copy or select something from command prompt while using nodemon; dont forge to press rs

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!