heroku-cra-node | use create-react-app with a custom Node server | Router library
kandi X-RAY | heroku-cra-node Summary
kandi X-RAY | heroku-cra-node Summary
️ How to use create-react-app with a custom Node server on Heroku
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of heroku-cra-node
heroku-cra-node Key Features
heroku-cra-node Examples and Code Snippets
Community Discussions
Trending Discussions on heroku-cra-node
QUESTION
I am a front end developer and am trying to get into full stack. I made a simple app to understand the workings of the MERN stack. I used this (https://github.com/mars/heroku-cra-node) as a basis to build it. The app works well in localhost but when I deploy it to Heroku, I get a Cannot GET / error.
server/db/mongoose.js
...ANSWER
Answered 2020-Oct-16 at 14:20Cannot GET /
QUESTION
I was looking at the https://github.com/mars/heroku-cra-node github repo and I noticed that in the package.json
, there is a script defined as "start": node server
(server being the name of the folder containing the index.js file).
What exactly does this line do? When we pass a folder name as parameter does node search inside of this folder for the file index.js
?
ANSWER
Answered 2020-Oct-12 at 22:13Short answer is, yes.
Long answer: package.json
is recognised by npm. So long as you have npm installed on your machine you can use it to do many things, such as install NodeJS modules, but you can also use it to run small scripts/commands. These commands must be added under the scripts
field in package.json
. To run these commands, you call npm run
. This feature is for convenience and doesn't have any bearing on package management. That being said, there are hooks available here that get called when publishing a package to npmjs.com (more on that later).
NodeJS will search for and import index.js
when importing any folder (CommonJS is probably being used by Node here, but I'm 100% not sure). So in your example, by calling npm start
, you are calling npm, which is calling node server
which is running server/index.js
. You could call anything you wanted here, for example, you could start a shell script by creating a script "my-script": "my-script.sh"
and then calling it via npm with npm run my-script
. This is a simple example, but not a very useful one - where npm-scripts comes into it's own is when you have complex commands you need to run regularly.
For example, you could have different commands to run a program with different contexts:
QUESTION
I keep encountering this problem when deploying my app. I have tried using serve-favicon but it hasn't worked.
My project can be found here (it's my first MERN stack project and it's not finished, so please don't comment on the code).
I am using this as a template for deploying MERN stack apps to Heroku.
EDIT: The problem had nothing to do with the favicon. The error displayed in the console was just the result of another thing failing to work properly. In my case, this was the connection to mongoDB Atlas. I changed my database to Heroku's mLab addon for mongoDB and everything deployed perfectly.
This error wasn't being logged on the console so I had to look at Heroku's logs to find what was wrong. See Here to learn about logging on Heroku.
...ANSWER
Answered 2019-Nov-26 at 16:41The problem had nothing to do with the favicon. The error displayed in the console was just the result of another thing failing to work properly. In my case, this was the connection to mongoDB Atlas. I changed my database to Heroku's mLab addon for mongoDB and everything deployed perfectly.
This error wasn't being logged on the console so I had to look at Heroku's logs to find what was wrong. See Here to learn about logging on Heroku.
QUESTION
I've created a basic app with Node backend and React frontend. I created a github repository and updated it with the changes. But due to configuration issues, I couldn't get the server working on Heroku.
So I searched through and found this starter-pack of create-react-app with a custom Node server on Heroku . I cloned it and updated the project. Now I hosted it on Heroku and it's working perfectly fine. Now I need it to push it to Github. I need to push it to the existing repository I've been working on(as it's the same project, just with working build on Heroku). As I'm on different projects (folders), how can I completely update my Github repository with this project ?
I have fine understanding with Git. When it comes to something like this(completely updating existing repository with new local repository) I'm getting confused. So, any help would be much appreciated.
...ANSWER
Answered 2018-Mar-23 at 06:02If you don't mind overriding completely your GitHub history with your new local repo, you can try:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install heroku-cra-node
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page