Heroku NodeJs Stuck in Build in Progress - node.js

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.

Related

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!

How to specify a file to heroku execute first

Im using node,js and getting this LOG from heroku, i think it is a missing file that heroku didn't find. but in the Json file i put the main file to my index.js but still not working and do not see any post about it
Build succeeded!
! This app may not specify any way to start a node process
https://devcenter.heroku.com/articles/nodejs-support#default-web-process-type
-----> Discovering process types
Procfile declares types -> (none)
Default types for buildpack -> web
-----> Compressing...
PACKAGE.JSON_IMAGE
The log you showed is fine.
Procfile is necessary when no proc is defined. The "default" for a nodejs buildpack is npm start.
In your package.json you defined under scripts what start does.
In Python projects you don't have something similar to npm start. So there you would have to create a Procfile with e.g. the content worker: python myproject.py
edit, package.json was added
Here is a project that is compatible with Heroku. It's on the heroku branch not master/main: https://github.com/d-zone-org/d-zone/tree/heroku
This is there scripts section in package.json
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "browserify web/main.js -t brfs -g uglifyify -o web/static/bundle.js",
"watch": "watchify web/main.js -t brfs -d -o web/static/bundle.js -v",
"start": "node index.js"
},
In your picture you don't have a start script defined.

Cannot find module '/app/dist/bin/www.js'

So I am having this error on Heroku. I just woke up this morning and found it after adding a new feature. It says my www.js file is not found. This file is not on GitHub. I am writing typescript so I'm guessing Heroku will build my project and create a "./dist" folder which will include the /bin/www.js file. The application was working before and still works locally. The application still builds successfully. I have tried adding a Procfile and also used a preinstall script but nothing seems to work. Is it possible to know if the "./dist" folder was successfully created?
Error on Heroku:
Folder Structure:
Scripts:
"scripts": {
"test": "SET NODE_ENV=test&& mocha --exit -r ts-node/register tests/**/*.ts",
"dev": "nodemon src/bin/www.ts",
"start": "nodemon dist/bin/www.js",
"build": "tsc -p .",
"lint": "eslint . --ext .ts",
"precommit": "npm run lint&& npm test",
"preinstall": "npm run build"
}`
The Procfile just has: web: npm start
I found the problem. Apparently, the new build created another www.js file in "dist/src/bin/www.js" and deleted "dist/bin/www.js" on Heroku. I have no idea why this happened. So I changed my start script to "nodemon dist/src/bin/www.js".

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