When we work with react, to start a server we use npm start command, why we don't use file name like App.js or index.js with it?
Asked
Active
Viewed 347 times
0
-
Possible duplicate: https://stackoverflow.com/questions/11716421/difference-between-npm-start-node-app-js-when-starting-app#11716667 – Quanta Jun 20 '20 at 18:22
2 Answers
0
In the package.json file, you have a property called "scripts", there you've got every scripts you can run by typing "npm run" in the console, if you take a look, "start" is one of them, and it usually runs a "node [filename]" kinda command. So, you are basically running an alias command.
Also, the reason you don't type "npm run start" its because a convention with the "start" command to be the default command, but I don't really know the specifics on that.

MaxHMoyano
- 57
- 5
0
I assume you are working with create-react-app? The command npm start
in this setup will start a webpack-dev-server. The starting file (index.js) is specified in the webpack config file, that is used by this server. So the file has to be specified, it is just abstracted away from you.

David
- 743
- 4
- 7
-
-
I hope this answer helps: https://stackoverflow.com/questions/48395804/where-is-create-react-app-webpack-config-and-files – David Jun 23 '20 at 19:17
-
However, if you want to customise the webpack config of create-react-app, there are some steps needed, see: https://medium.com/@ryoldash/customize-webpack-config-of-react-app-created-with-create-react-app-7a78c7849edc – David Jun 23 '20 at 19:18