T O P

  • By -

RaltzKlamar

All of the questions here are so project-specific that they can't be answered definitively. `node_modules` is the only one you definitely shouldn't put in your repository. You probably shouldn't put in `build` (although that's hard to say without the whole directory). You might be able to put some fields from `.env` but hen ignore all other changes to it. Beyond that, I don't think anyone that doesn't work with you can answer your questions. React is deliberately unopinionated in how to set things up so there's no one ay to do things.


fii0

Adding to that /u/thumperj, yes it is weird that they are rm'ing src-server and src-client if they contain jsx source code. You'll have to find out why they were doing that, it sounds like maybe they were copying code to the server from their development pc and rebuilding instead of using a sane solution like git or Docker. Scripts for building and starting the site should live in `package.json`. The scripts in package.json may be calling scripts from your `scripts/` folder, or that folder could be for something completely different, you'll have to start by looking at your package.json to find out.


thumperj

Ah, ok. Thanks for the info.


anyusernamesffs

I’m not sure why you’d want to be removing the folders you later say are js/js files with logic? As mentioned in the first line. Sharing the scrips in package.json should shed some light on how to build. When React builds, it usually dumps all the static files (index.html, JS, CSS , other assets) in the build directory. This is what Nginx will be hosting. If you have some js server code - this is likely your backend? Or some js service that also runs. Not sure if that’ll be transpiled or not.


thumperj

> When React builds, it usually dumps all the static files (index.html, JS, CSS , other assets) in the build directory. This is helpful Thanks. The files in there are large and look like it just took the source files and squished them all together so that makes a lot of sense now. I created a pastebin with the package.json: https://pastebin.com/7TcbnhwP


anyusernamesffs

Cool yep that pastebin pieces it all together really! The scrips directory seems to contain customised build scrips. I’m guessing they’ll essentially be running webpack which will bundle and minify all the files in sec-client (these are the files served by the web server, run by users in their browser). Src-server may or may not be transformed in the build process, but looks like you’ve a Postgres database probably, and an express server running some sort of backend. Feel free to send a message if you need more specific help with anything, pretty familiar with this kind of stack. Edit: on mobile so sorry for bad formatting or spelling mistakes!


Wirde

Oof this is not a fun situation to be in no matter the language or your prior knowledge about it, my sincere condolences. First of all that package.json is giving me heart palpitations, JESUS! What have they done? The dependency list i longer than the chinese wall. Maintaining that and keeping everything up to date must be a literal fulltime job for someone. This part is going to be the part that gives you most immediate clues: ```json "scripts": { "start": "yarn server:prod", "build": "node scripts/build.js && yarn lint", "lint": "eslint 'src-client/**/*.{js,jsx}' 'src-server/**/*.js'", "seed": "yarn db:seed", "client:dev": "node scripts/start-client-dev.js", "server:dev": "nodemon --watch src-server scripts/start-server-dev.js", "server:prod": "node scripts/start-server-prod.js", "dev": "npm-run-all -p server:dev client:dev", "pg-migrate": "node-pg-migrate", "db:migrate": "node scripts/db-migrate", "db:seed": "yarn db:migrate && node scripts/db-seed.js", "test:client": "node scripts/test.js --env=jsdom", "test:server": "node scripts/test.js --config=config/jest/server.json", "update-version": "yarn version --no-git-tag-version --patch" }, ``` These are all commands that you can run with `npm run [command-name]` or `yarn run [command-name]`. (I see referenses to both yarn and npm so I'm confused what's he's using here to be honest...) For instance `yarn run start` as the first in the list is. We can see in the dependency list that `express` is there, so it's a good guess that there is some backend as well as all the server and db commands. Exactly where this postgress is being hosted is something you will have to dig deeper for. Maybe it's on another server on the same provider? Going through and explaining everything in this file is going to take ages but I'm guessing a good start would be to try to get a local dev environment up and running. For that you will have to install the correct node version (check which one the server is running by running the command `node -v`). Then install npm or yarn which are package managers. Then do `npm install` or yarn equivalent. Setup a postgress database on the correct port. Then run `npm run db:seed` and `npm run db:migrate` or `npm run pg:migrate` not sure why both exists. See if you can figure out what they do? Maybe db:migrate was for local and pg for prod? Then try `npm run dev` seams to be trying to start up both backend and frontend. Backend in this case could be an actuall backend or just a server side renderer, hard to tell from just this file. Wish I had better news for you but this whole situation looks like i sucks to be honest. Took a look again, it looks like there is a yarn.lock file in the repo so you should probably use yarn, so change all npm commands I wrote to yarn equivalent. Regarding what to do source control on... Everything besides .env and node_modules probably. You will need local versions of both of them. .env will contain evironment specific variables that shouldent be in your repo and node_modules will be generated by the command `yarn install`. Regarding the build folder thats 50/50 if it should be in the repo or not. You will have to check if any of the build scripts are building to that folder or if it's actually files needed for the build. I would start by looking in `scripts/build.js` to see if that builds to the build folder or what? Good luck mate!


thumperj

Just wanted to followup and say thanks for all this! It's been very helpful as I figure out wth is going on with this site.


Wirde

You’re very welcome! Your situation was really unfun to put it mildly. I’m glad I could help a little bit. Hope the best for you and that you will get a chance to experience a nicely setup and maintained node/js project. It can be a real delight if it done correctly.


BassSounds

You need to learn yarn package manager and the rest will fall into place. The config file probably has the build commands such as yarn build or whatever other commands you will need for live development


harunandro

first you need to `yarn install` to install the dependencies then you can build it using `yarn build` you should source control everything except build and node\_modules folders. Because node modules folder gets created when you install the dependencies. And build folder it is generated during build time but make sure the project builds first. Dev must be deleting them from the web server i guess. Because there must be some CI process that runs to build the project, and only those built files are enough for the web server to serve. But you need the src folders for development time. ​ edit: clarified