title: Nodejs: How to prepare code for production environment
body: <p><em>I'm a beginner developing with Nodejs and React</em>. </p>
  
  <p>Right now, I've got a first version of my web application which works correctly in development environment, but I'm trying to build a version for production environment but I've got this error </p>
  
  <blockquote>
    <p>ReferenceError: document is not defined</p>
  </blockquote>
  
  <p>The scripts of my package.json are:</p>
  
  <pre><code>  "scripts": {
      "dev-webpack": "webpack-dev-server --hot --mode development",
      "clean": "rm -rf ./dist",
      "dev": "npm run build-dev &amp;&amp; cross-env NODE_ENV=development nodemon --exec babel-node src/server/server.js --ignore ./src/client",
      "build-dev": "npm run clean &amp;&amp; npm run compile-dev",
      "compile-dev": "NODE_ENV=development webpack -d --config ./webpack.config.babel.js --progress",    
      "compile": "NODE_ENV=production webpack -p --config ./webpack.config.babel.js --progress",
      "build": "npm run clean &amp;&amp; npm run compile",
      "start": "npm run build &amp;&amp; node ./dist/assets/js/bundle.js"
    },
  </code></pre>
  
  <p>And I try to create the version for production environment with the command <code>npm run start</code></p>
  
  <p>I have been looking for information about the problem and it seems it's due because I have no Browserify my web application. But, I don't know how to do this correctly nor the steps to follow to do it correctly.</p>
  
  <p>I am seeking a list of the steps required to build a correct version for production environment.</p>
  
  <p><strong>Edit I:</strong></p>
  
  <p>These are the static files generated with "build" script:</p>
  
  <p><img src="https://i.stack.imgur.com/EYjvq.png" alt="enter image description here"></p>