Giter Club home page Giter Club logo

cogs121's Introduction

Accompanying YouTube video playlist: https://www.youtube.com/playlist?list=PLzV58Zm8FuBIWu1zvGRUfn0Xh6HXRg9cG

Tips for building Node.js web apps for your team project

  • Download and use a LTS (long-term support) version of Node.js instead of the latest one since LTS is more stable.
    • Try to make sure all of your teammates have the same versions of Node.js and npm installed (run node -v and npm -v to check your version numbers).
  • Do not put node_modules/ in your Git repository. Look at .gitignore to see how I've ignored it from my repository.
  • When you run npm install it will install the modules listed in your package.json file; to install individual modules that are not listed in package.json you need to explicitly mention their names: e.g., npm install sqlite3
  • Since you're using JavaScript on both the frontend and backend, make sure you're aware of which code should go in the frontend and which should go in the backend. For instance, you should not use jQuery (e.g., $.ajax()) in your backend code.
  • Use console.log() in both your frontend and backend code to understand what code is executing and when
    • be especially aware of asynchronous code and callback functions, since they often execute not in the order you're expecting
  • Always remember to save your code, restart your server, and reload your frontend in your browser to see the latest edits. nodemon can automatically restart your server for you, and some browser extensions can auto-reload webpages.
  • Glitch provides free web hosting and an entirely web-based coding environment for Node.js apps. It can also sync with your team's GitHub repository. Feel free to try it as one possible way of getting rid of incompatibilities between setups on your teammates' computers. (It's not mandatory, though.)
  • To get around cross-domain restrictions that some APIs have, the easiest way is to make the API requests from your Node.js backend instead of from your frontend JavaScript code. Then your frontend JavaScript (in browser) can make regular ajax requests to your Node.js backend to query that data. The "request" module is a popular one for making API requests on the backend. (blog post)
  • A good general strategy for debugging is to start with a WORKING version, such as trying to get the petsapp tutorial working, and then slowly evolve that version into what you need to do. If you start with something that doesn't work and find yourself semi-randomly commenting out lines, adding lines of code, etc., then that is not a systematic debugging strategy. Instead, try to make a super-simple working version of your code (potentially based on the petsapp tutorial code). And use lots of console.log() statements in both your frontend and backend code to figure out what code is executing and with what values.

cogs121's People

Contributors

pgbovine avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.