How to get heroku to detect nodejs buildpack? - node.js

I am trying to deploy a web app to heroku but keep getting this error:
`-----> Failed to detect app matching https://codon-buildpacks.s3.amazonaws.com/buildpacks/heroku/nodejs.tgz buildpack`
Here is a simplified look my app file structure:
myProject
|__server
|__server.js
|__react_component_1
|__react_componet_2
|__styles</p>
The express server is the server.js inside the server directory and it will the entry way to my app.
It seems like this question has been asked many times before and I've read all the answers, here's what I have tried:
I am deploying from the root folder, myProject, which did not have a package.json file. I've tried npm init to set up a package.json so heroku can detect the app as nodejs. I've also made sure that package.json is being tracked by git. I've made a Procfile: web: cd server && npm run start. I have run the command in the cli to set buildpack: heroku buildpacks:set heroku/nodejs but so far none of it has worked. I've also tried buildpacks:clear after setting everything up to see if heroku can automatically detect buildpacks now that I have a package.json.
Any help is appreciated, thank you.

According to Heroku's relevant documentation on Node.js buildpacks:
The Heroku Node.js buildpack is employed when the application has a package.json file in the root directory.
Based on your Procfile content, web: cd server && npm run start, that looks like you ran npm init inside the server directory, not the root directory.
I think if you move package.json and the node_modules folder one directory down to the root, the buildpack issue will be resolved. Just make sure to change your Procfile to web: npm run start because it would be the same directory now.

Related

deploying Node on heroku error after build successful

i have been trying to deploy a node.js app on heroku. the app run successfully on local machine and it build successful with git heroku push master. but when try to open the app on heroku, it shows a blank page and on the console i got the bellow error.
so i my app i uses owlcarousel, and react -carousel. thanks
Try running it locally with NODE_ENV=production node index.js to see if you can reproduce the error like that. Check the .gitignore to see if you are not leaving out some important files. Check the package.json If a module that is included in the package.json is missing from the build or the production app, it may have been removed by Heroku during pruning. And also, in order to create a smaller slug size for apps, the buildpack will prune out the devDependencies from the package.json at the end of the build, so that the slug will only include the dependencies that are listed at runtime. If there is a dependency that is in the devDependencies that is needed after the prune occurs, move the dependency to dependencies, so it is not removed. Look here for more info, troubleshooting Node.js deployment on Heroku.

How do I change heroku from web npm start to worker npm start?

I have a heroku app that doesn't have a website - however, I mistakenly set it up with a web npm start. I'm looking to fix it as it's been throwing an error about failing to bind to $PORT. How exactly should I change it?
EDIT: Directory: src folder, .gitignore, Procfile, readme.md, package-lock.json, package.json
Content of Procfile: worker: npm start

Running node.exe from Django on Heroku - [Errno 2] No such file or directory

I'm deploying a Django project Heroku. I need to run node.exe, so I copied node.exe to my folder and deploy all them to Heroku.
Here is the code use with node in Django:
def extract_eval_unpacked(text):
with io.open('temp.js','w',encoding='utf-8') as f:
f.write(text)
cmd = 'node.exe temp.js'
process = subprocess.check_output(cmd,shell=False)
if process:
return process.decode()
return None
This works locally, but when run on Heroku I get
[Errno 2] No such file or directory: 'node.exe temp.js': 'node.exe temp.js'
I checked on Heroku and I see node.exe:
$ heroku run ls
Running ls on ⬢ extractmedia... up, run.4541 (Free)
1 client_id.txt manage.py Procfile.windows runtime.txt test1.py
1.py gettingstarted node.exe README.md staticfiles
app.json hello Procfile requirements.txt temp.js
Why isn't this working, and how can I fix it?
I need to run node.exe, so I copied node.exe to my folder and deploy all them to Heroku
Don't do this.
Heroku doesn't run Windows, so it won't be able to execute a Windows binary like node.exe. There's a much better way to add Node.js to your application: use multiple buildpacks.
Set your main buildpack:
heroku buildpacks:set heroku/python
Add a second buildpack for Node.js:
heroku buildpacks:add --index 1 heroku/nodejs
Check your buildpacks and make sure that Python comes last:
heroku buildpacks
Add a package.json file to the root of your repository, e.g. by running npm init or yarn init.
If you depend on any specific Node.js libraries, include them as dependencies, e.g. via yarn add or npm install --save. Commit this file.
Update your Python to call node instead of node.exe. Commit that change.
Deploy.
You should see Node.js and any JavaScript dependencies get installed, followed by Python and all of your Python dependencies. node should be available at runtime.

Deploying App on heroku node command not found

I have basically modified this app
https://github.com/heroku/node-js-getting-started.git
Now am trying to deploy in Heroku
My Procfile has this line
web:node index.js
And when I run this command locally,there are no probs..
However if I try to open the link in my browser after following all the steps in https://blog.risingstack.com/node-hero-deploy-node-js-heroku-docker/
I get an error
On checking the logs using heroku logs command I am getting 'node command not found'
Anyone knows the prob?
P.S : I tried changing Procfile contents to npm start but that doesnt launch index.js in the browser.
I suspect that you have not set the buildpacks. Buildpacks tells heroku which kind of application is yours.
Use the below command to set the application of type nodejs.
heroku buildpacks:set heroku/nodejs
And make sure that you have a package.json file in the root of the project which is read by heroku to install the project dependencies.
Why don't you try this below in your Procfile.In my case it runs nicely.
web npm install
You just need to add nodejs buildpack on heroku settings app,
after that you will be able to use npm commands.

Local or Private NPM module when deploying to Heroku

I have a node app that has a local npm module npm link ./local and I'm trying to deploy the app to heroku. Heroku runs npm install when I deploy, but npm link's aren't saved in package.json so my local module is missing.
I'm new to heroku and Procfiles, I'd like to run a script or just run npm link ./local before on the heroku box.
Alternatively I could put the module on github as a private repository and link it from there. But as far as I know Heroku isn't able to download private repo. Can I give Heroku access to my github repository via keys so that it could download it?
I'd love for somekind of solution! Anything!
I think you need yo put modules in node_modules folder and push that to heroku
Procfiles are easy to maintain and heroku will read that
I have sample Procfile like
web: bin/hubot -a campfire
Even heroku also says that best is to include node_modules into repo so you can just include your local packages into that.
See more here Heroku Node Deploy

Resources