All other scripts must always be prefixed by npm run so the dev script would be run with npm run dev. Install express for your project npm install expressĬreate a server.js file with the following codeĮnter fullscreen mode Exit fullscreen modeĬonvention holds that the start script is used for the command to run the application in production, reason being is that start is the only script that can be run two ways npm start or npm run start. Install nodemon globally npm install -g nodemon Must have NodeJS installed and IDE (I'm using Visual Studio Code)Ĭreate a new node project with npm in terminal npm init -y I'll try to emulate the Object Oriented Patterns you may see in other frameworks like Rails, Lavavel and Django, but this isn't required for Express which gives you complete freedom to structure your files and project as you with. If you ever use a different web framework in another language, you'll find many of the patterns in this tutorial still apply. To run non-javascript code (a web server can be written in any language, frontend application must use javascript since the browser doesn't understand anything else)Īs I mentioned, we can write a web server in any language and that includes javascript since we can run javascript outside of the browser using runtimes like NodeJS and Deno. Working with the file system to read and write files Making requests to databases or other web applications (Web APIs), where you'll likely want to hide credentials (nothing on the frontend is secret, nothing). This works great for many use cases, but eventually you are going to need to run code that can't run in the browser for purposes such as: If you've deployed soley frontend projects using Github pages, Netlify, or Vercel they allowed their own web application serve your files for you so you don't have to make your own. Whenever you type a url into a url bar in the browser and hit enter, the browser on your behalf is sending a request to a web application somewhere that determines what to send back like an html file or JSON data. A web server or web application, is an application that runs and listens for incoming http requests and responds to them.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |