'How to push React with .Net core application to heroku?
I have completed making one application using react in front end and .net core at backend. Now I need to publish this repository to heruko. Locally, when I do dotnet build and run it it works fine but while pushing it to heroku i am getting an error
: /bin/sh: 2: /tmp/tmp35fd435a650b4b94a93ab28064f9c447.exec.cmd: npm: not found remote: /tmp/build_46ea6d26/API/API.csproj(50,3): error MSB3073: The command "npm install" exited with code 127. remote: ! Push rejected, failed to compile ASP.NET Core app. remote: remote: ! Push failed remote: Verifying deploy... remote: remote: ! Push rejected to librarymanagementsysteminsight. remote: To https://git.heroku.com/librarymanagementsysteminsight.git ! [remote rejected] master -> master (pre-receive hook declined) error: failed to push some refs to 'https://git.heroku.com/librarymanagementsysteminsight.git'
What am I missing here?
Solution 1:[1]
I can give you a checklist respectively,
- Check ASP.NET CORE compiled version
- Check ASP.NET CORE runtime version
- Check you npm version
- Check your folder that base of your heroku app, specify it according to language. You do not run npm in your ASP.CORE folder
- Check permissions of your git repo
Also, you are trying to push your code into master. It is not recommended. Create Branch and use it to push.
Solution 2:[2]
You need to use 2 buildpacks:
heroku buildpacks:set https://github.com/jincod/dotnetcore-buildpack
heroku buildpacks:add --index 1 heroku/nodejs
Asp.net core with react demo app deployed to Heroku https://github.com/jincod/AspNetCoreDemoApp
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Sabri Korkmaz |
Solution 2 | jincod |