D
D
Denisca Gareev2020-07-26 11:22:04
Node.js
Denisca Gareev, 2020-07-26 11:22:04

How to run a module with a command?

I wrote a module that creates a web server on a local PC but there is one inconvenience. When starting, I have to go to the module directory and write the following command: node index.js C:/Projects/the_sitethat is, I have to specify the path to the site folder.
And the question is: how to run a module in a different directory with a command like:web-server ./

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dima Pautov, 2020-07-26
@bootd

package.json

//....
"scripts": {
  "dev": "node index.js"
  // Или
  "web-server": "node index.js"
}
//....

then justnpm run dev

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question