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" }
Related
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.
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 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!
I am having an interesting problem building my typescript server using nodemon. I have a script for building out the ts files, and then starting the server. However, when I run these two concurrently, it starts at first fine, then after it is done building, it restarts, but gives me an error that the port is already in use. Is there a way to somehow kill the port each time before it starts?
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start:dev": "nodemon dist/index.js",
"build:dev": "tsc --watch --preserveWatchOutput",
"dev": "concurrently \"npm:build:dev\" \"npm:start:dev\""
},
I have tried adding "npx kill-port 8080 && nodemon dist/index.js" to the start:dev, but I am still getting that error. I have also tried "npx kill-port 8080; nodemon dist/index.js" Is there a solution to this issue? Thanks.
Edit: It seems that this is actually working as I expected it too however, for some reason the terminal is still showing an error message and therefore, anything my server logs to the console is hidden. Is there any way to fix this? Thanks.
I am not sure why exactly you get a port error, but you can improve your setup. Nodemon can run typescript with ts-node help.
Just install ts-node and run nodemon with --exec 'ts-node' property.
Example from my package.json:
{
"dev": "nodemon --watch 'src/**/*' -e 'ts' --exec 'ts-node' src/index.ts"
}
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.