We help IT Professionals succeed at work.

Help with running my Node project

Hello experts.  I am having some trouble running one of the group projects we created in our bootcamp.  If I may, describe the issue and can you recommend which additional files to attach to help with the detective work?

This was a working project that we presented(it was on a different laptop than mine).  I pulled it down from Github onto my laptop.  I worked through a few roadblocks and I do have it running on my localhost. Unfortunately, the html page that is loaded is blank.  When I open the html file in a Sublime  there is no markup in it.  I attached the index.html file.  There are comments in it I do not understand.  I was responsible for the backend while another team member took care of the frontend

1)
Here is what I have in the server.js file for the html page:

app.get(function(req, res) {
   res.sendFile(path.join(__dirname, "./client/public/index.html"));
});

2)
I attached a screen print of the browser console when the index.html file opens empty.







Thank you for your patience and help,
Ed
Comment
Watch Question

Most Valuable Expert 2018
Distinguished Expert 2019

Commented:
Generally, when writing a Node app, you create the source files, and then you 'build' your application. The build process is responsible for compiling all of your assets into usable files, and injecting them into the index file. Often, the built assets will be placed in a specific folder such as 'dist' or 'build'

You run the build process by running one of the scripts available in your package.json file such as dev, build, test etc:

npm run build

Generally, there is also a dev script to allow you to launch a server for testing:

npm run dev

Author

Commented:
Thank you. I will try tonight.

Author

Commented:
Hello

I did not have much luck.  I do not understand why there are 2 package.json files.  

There is one in the same location as my server.js file.  I  navigated in Bash to the path where server.js file is located. When I type node server.js and then check localhost that is when I get the blank screen.  

Then up one level in the client folder there is another one.
So, in light of finding the second package.json file, I navigated in Bash into the client folder.  Then tried npm run start and received message " 'react-scripts' is not recognized as an internal or external command".  

Can you offer suggestions on what to try next?  

Thanks,
Ed
package.json
package.json
Most Valuable Expert 2018
Distinguished Expert 2019
Commented:

Hi,


Not sure what's going on, but an application can have several package.json file. There will be one for each project, so if your project contains other projects, they may all have there own package.json.


In the folder with json for project-3, make sure you've installed all the dependencies:


npm install


Once you've done that, run the following:


npm run start


You may need to make sure the dependencies are installed for your other app (rccrafter). Switch to that foler and run npm install

Author

Commented:
Thank you for the help. It is working now!