How to deploy node.js?

  node.js, question

I made a small application with node.js and react. Before writing node.js or PHP, it was written directly and run on the server. This is the first time to use such tools as babel and webpack. Now I have no idea how to deploy them. I hope I can get some advice.

My local project package is in insidesrclibAndnode_module3 folders. All the codes I write are in src inside. Lib is babel’s output folder, should this be the actual running file?

React uses webpack, webpack-dev-server and react-hot-reload. Static files at the front end are all provided by webpack-dev-server. Webpack outputs an app.js (hard disk inside does not), which is referenced in HTML inside. Other. js and. css files are manually written in HTML inside and referenced from the webpack-dev-server address.

The local runtime is started and monitored with nodemon. Nginx is on my server, and a node.js app was running before, which was started and monitored by pm2. I know how to configure Nginx and how to use pm2, but before I wrote the code directly and ran it directly, not involving babel and webpack, nor did I join React.

Question 1: Should I put the entire project folder on the server or just put thelibPut the folder on? Is it the dumbest way to debug the whole system in the local arealibPut it as a complete project and run it like a normal app?

Question 2: How to deal with static files in HTML, you need to manually change HTML inside’ssrcChange to local or CDN address?

Question 3: I saw that it was said to pass through Express inside.configureSetting up different environments, what is the function and thinking of this? Are there necessary steps?

Question 4: I still need to continue the development after uploading to the server. Previously, I directly edited files and updates online through FTP (FileZilla uploaded automatically). It is not clear whether this can still be done. In other words, it still needs a development environment to upload to the server.

Question 5: How do you understand the switching between development environment and production environment? Is this a physical action, such as changing to a different server, modifying some files, or just setting one or two parameters?

Sorry, the problem is scattered and basic. I hope it is best to have an introduction to the thinking and working methods. I need to know how these tools work, otherwise just looking at the sample code and even step-by-step is not very useful.

Question 1: Should I put the entire project folder on the server or just the lib folder? Is it the dumbest way to debug the lib directly after all the local debugging is finished?
Put it as a complete project and run it like a normal app?

I am not familiar with babel, so I am not very clear. I guess I should put lib on it.

Question 2: How to handle static files in HTML, need to manually change the src of HTML inside to local or CDN address?

A build step is required.https://medium.com/@okonetchnikov/long-term-caching-of-static-assets-with-webpack-1ecb139adb95

Question 3: I saw that it was said to set up different environments in Express inside through configure. What is the function and thinking of this? Are there necessary steps?

Read NODE_ENV, for example, when you test, you may need to hang some internal url or use a test database.

Question 4: After uploading to the server, I still need to continue the development. Previously, I directly edited files and updates online through FTP (FileZilla
Automatic upload). It is not clear whether this can still be done. In other words, it still needs a development environment to upload to the server.

Yes, but it is not particularly necessary. Can be directly developed and uploaded locally

Question 5: How do you understand the switching between development environment and production environment? Is this a physical action, such as changing to a different server, modifying some files, or just setting one or two parameters?

Set parameters, if NODE_ENV is production, read this database, if not, read that database