Deploy Rails + React app on Amazon EC2 blank page issue - node.js

I have application with the combination of rails 5 + react.js. I am have deployed it on Amazon EC2 server. Application setup is done. There is no error till now.
Issue is "Getting Blank Page". Contents are not being rendered on the screen.
Node modules are already installed on server.
Code from my package.json file
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"webpack": "./node_modules/.bin/webpack --watch",
"heroku-postbuild": "webpack --config webpack.config.prod.js"
}
Tell me what's going wrong.

Related

Heroku NodeJs Stuck in Build in Progress

I created a test-backend with NodeJs and tried to deploy it to Heroku.
I followed the instructions and the command git push heroku master was successful.
The app should have been deployed, but instead it is stuck in "Build in progress", as you see here:
The last lines shown in the build log are:
-----> Build
Running build
> test-backend#1.0.0 build /tmp/build_2dd56f0f
> tsc -w
c2:11:15 AM - Starting compilation in watch mode...
2:11:19 AM - Found 0 errors. Watching for file changes.
It seems that Heroku is running my build script, I don't know why and why is it a problem.
My package.json scripts are as follow:
"scripts": {
"dev": "ts-node-dev src/index.ts",
"lint": "ts-standard",
"build": "tsc -w",
"start": "nodemon build/index.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
Any idea of what is happening?
I deleted my Build script in package.json and managed to deploy the NodeJs project to Heroku.

npm start is starting the server.js not my React app, how can I use it to start my app?

So I was having this issue of node not restarting the server when there changes made on the server.js file. I fixed it by editing the package.json file. However, once fixed, the npm start command starts the server.js file: [nodemon] starting `node server.js
How do I start my react app then? npm start was the command I used before
Most probably your set your package.json file to
"scripts": {
"start": "nodemon server.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
Change your server package.json to something like this:
"scripts": {
"server": "nodemon server.js",
"test": "echo \"Error: no test specified\" && exit 1"
then run the command
npm run server --this will start your server.js
Nodemon has nothing to do with the client-side(React app). So, before running npm-start:
Make sure you are in the correct directory cd [directory-name]
It's better to separate your front-end and back-end in a separate folder

I am facing problem in running the backend of a github repository

I hope you are doing great,
I am trying to cloning one of the Github repository,
here's the link to repo:
https://github.com/thevarunjain/job-portal-mern-stack
I've done everything according to my knowledge, I've run the MongoDB, install all the dependencies by npm I, frontend is running successfully but whenever I run the backend "npm run dev" am getting this error:
** ./node_modules/.bin/nodemon src/index.js
'.' is not recognized as an internal or external command,
operable program or batch file. **
here's the script of package.json:
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node index.js",
"dev": "./node_modules/.bin/nodemon src/index.js"
}
Please let me know how can I fix this issue, thanks!

Deploying simple nodejs app to Heroku - Procfile not working

I'm trying to deploy my Express server to my Heroku app, but every time I do, I get an error and it crashes.
I setup my Procfile with the following code: web: node /src/server.js
Where server.js is not in the root of the directory. However, when I try to start the server, I get an error in the logs: Error: Cannot find module '/src/server.js'
When I run the app locally, I have to run npm start in order for it to run the server correctly. Here is the relevant "scripts" portion of my package.json file:
"scripts": {
"start": "NODE_ENV=dev nodemon ./src/server.js --exec babel-node",
"prebuild": "rimraf dist",
"build": "babel ./src -d dist --presets es2015,stage-2 --ignore spec.js,node_modules",
"serve": "NODE_ENV=production node dist/server.js",
"start_babel": "babel-node ./server.js --preset=babel-preset-es2015",
"test": "echo \"Error: no test specified\" && exit 1",
"lint": "eslint ."
}
Since the Procfile overrides the package.json script commands, why is it having trouble finding my file when I've explicitly set it?
I'm not sure about the leading slash. Does using ./src/server.js help at all?

Deploying a Node.js app using Heroku - start script

I'm quite puzzled as to why my app is crashing when deployed to Heroku.
The error is
Failed at the ev#1.0.0 start script.
Where my start script is
"start": "node app.js"
because app.js is where it is all initialised (in the same place as package.json, of course).
My app works perfectly fine locally, i.e. it starts app.js and successfully runs, so what could be causing this issue remotely?
You must sure that you write "start": "node app.js" inside the script. Because Heroku Read this Scripts to start the nodejs Server i.e
"scripts": {
"start":"node app.js"
"test": "echo \"Error: no test specified\" && exit 1" }

Resources