title: How to "upload" my nodejs source code to production server?
body: <p>I am not asking about deploying Node.js app or how do I deal with node_modules package, I am talking about "upload" my own nodejs code to production server. </p>
  
  <p>So far I have tried 3 ways, each with its own pros &amp; cons</p>
  
  <p><strong>git clone</strong>. To reduce to the cloned stuff I use <code>git clone --depth 1 -b release_branch</code>. But still I got the files I do not need for deployment, e.g except for <code>.git</code> I also get documents (b/c I put documents in my git repo).</p>
  
  <p><strong>npm install</strong>. use <code>npm install git+https://gitusername:gitpassword@myserver/path/to/repo.git</code>. With proper <code>package.json files</code> setting I can get my source codes only, which is what I want. But the problem is the directory structure. After running npm install, the directory is like this,</p>
  
  <pre><code>.
  ├── node_modules
  └── package-lock.json
  
  My package is located inside node_modules alongside with its own dependencies.
  </code></pre>
  
  <p><strong>npm pack</strong>. Then upload (scp in my case) the tgz file to server, then <code>npm install tgz_file.tgz --production</code>  But it has the same problem with npm install git+https. It is probably better than <code>npm install git+https</code> b/c I can control my releases.</p>
  
  <p>So is there other ways (simple) that I can get proper directory structure and source codes only ?</p>
  
  <p>BTW, I know this <a href="https://stackoverflow.com/questions/38651764/nodejs-express-app-deploying-to-production">nodejs express app deploying to production</a> but their discussion is not the same as mine.</p>
  
  <p>----- update -----</p>
  
  <p>Now I am kinda sure <code>npm install tarball</code> has some bug, so I just <code>tar xf &amp; npm i</code> I believe this is the simplest solution.</p>