lmammino / judo-heroes-2

Universal Javascript sample application with React Router 4 and Express 5 (Enhanced version of https://github.com/lmammino/judo-heroes)
MIT License
177 stars 48 forks source link

How do I host this on a server? I can't find the index.html after running build. #18

Open davidfufu opened 6 years ago

davidfufu commented 6 years ago

The build commands don't create a build directory with an index.html. I'm stuck. I was wondering if the static folder was the build folder. It has the bundle.js file, but i don't see any html files? Can anyone shed some light on this?

lmammino commented 6 years ago

Hello @davidfufu, to run this on a server, you will need to have node/npm installed and then run:

npm run start:universal

Let me know if this helps you 😉

davidfufu commented 6 years ago

So, I took a shot at hosting it on heroku. I got the log files from the initial install.

-----> Node.js app detected
-----> Creating runtime environment

       NPM_CONFIG_LOGLEVEL=error
       NODE_VERBOSE=false
       NODE_ENV=production
       NODE_MODULES_CACHE=true
-----> Installing binaries
       engines.node (package.json):  unspecified
       engines.npm (package.json):   unspecified (use default)
       engines.yarn (package.json):  unspecified (use default)

       Resolving node version 8.x...
       Downloading and installing node 8.11.2...
       Using default npm version: 5.6.0
       Resolving yarn version 1.x...
       Downloading and installing yarn (1.7.0)...
       Installed yarn 1.7.0
-----> Restoring cache
       Skipping cache restore (not-found)
-----> Building dependencies
       Installing node modules (yarn.lock)
       yarn install v1.7.0
       [1/4] Resolving packages...
       warning snyk > proxy-agent > socks-proxy-agent > socks@1.1.10: If using 2.x branch, please upgrade to at least 2.1.6 to avoid a serious bug with socket data flow and an import issue introduced in 2.1.0
       error Your lockfile needs to be updated, but yarn was run with `--frozen-lockfile`.
       info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
-----> Build failed
 !     Outdated Yarn lockfile
       Your application contains a Yarn lockfile (yarn.lock) which does not
       match the dependencies in package.json. This can happen if you use npm
       to install or update a dependency instead of Yarn.
       Please run the following command in your application directory and check
       in the new yarn.lock file:
       $ yarn install
       $ git add yarn.lock
       $ git commit -m "Updated Yarn lockfile"
       $ git push heroku master

       https://kb.heroku.com/why-is-my-node-js-build-failing-because-of-an-outdated-yarn-lockfile
 !     Push rejected, failed to compile Node.js app.
 !     Push failed

So I see it's a problem with the yarn.lock file, and I take the following steps: 1.I fork your repo

  1. clone it on my pc and run "yarn install"
  2. I commit and push the new yarn.lock changes onto my forked rep
  3. i create the heroku app and choose github as the deployment method
  4. I link my forked repo and it says the deployment was successful
  5. I click view app, and all I get is the error
Application error
An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details.

When I inspect the webpage, the console has one error:

Failed to load resource: the server responded with a status of 503 (Service Unavailable)

Then, I go to the heroku console and type in npm run start:universal and get the following error:


> judo-heroes-2@1.0.0 start:universal /app
> export UNIVERSAL=true && npm run start

> judo-heroes-2@1.0.0 start /app
> npm run build && node src/server-es5.js

> judo-heroes-2@1.0.0 build /app
> NODE_ENV=production webpack -p --profile --display-modules --optimize-minimize

sh: 1: webpack: not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! judo-heroes-2@1.0.0 build: `NODE_ENV=production webpack -p --profile --display-modules --optimize-minimize`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the judo-heroes-2@1.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /app/.npm/_logs/2018-06-06T20_43_09_639Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! judo-heroes-2@1.0.0 start: `npm run build && node src/server-es5.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the judo-heroes-2@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /app/.npm/_logs/2018-06-06T20_43_09_686Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! judo-heroes-2@1.0.0 start:universal: `export UNIVERSAL=true && npm run start`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the judo-heroes-2@1.0.0 start:universal script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /app/.npm/_logs/2018-06-06T20_43_09_724Z-debug.log

Help me out bro!!!

lmammino commented 6 years ago

Sorry for the late reply. It seems you have two problems here. an outdated yarn file and missing webpack in your heroku build pack. Not sure how to address both at the moment, but i am sure you can find something online.

Regarding yarn, i am sure if you just delete the yarn lock and re run yarn that should fix the issue. Regarding webpack there must be some webpack enabled build pack for heroku