Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

194
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda