Search code examples
node.jsexpressweb-applicationsbrowserifyweb-hosting

Which files from Node.js app must be uploaded to a web-hosting?


Perhaps this is a silly question. It came out while I was learning how to set up a Node.js application for production on Ubuntu and digital ocean.

Let's say I have a simple data visualization app made in Node.js, using node modules such as express, page, axios, yo-yo, and browserify to compile my files.

I want to upload my app to a webhost that already exists.

This is the structure's app:

  • node_modules
  • public (app.js and app.css)
  • src (header, home, and footer folders)
  • views (index.pug file)
  • gulpfile.js
  • index.scss
  • package.json
  • server.js

Which files I need to upload in order to see my app as I see it in localhost?


Solution

  • You need to upload everything.

    What Maximelian says is true if you're going to run npm install again on your server. The standard way of doing this is sync the project using git (you can find a .gitignore template for node.js here).

    Once setup you'd do something like this on the server after making the commit locally, and pushing to your remote git repo:

    git pull
    npm install
    npm start
    

    If you were to just ftp the full working project including node_modules it would work just by running npm start. But the above method is what I'd recommend.