I'm currently new to the MERN stack, and whole nodejs scene. I'm just wondering how you can reference a package.json file from a sibling directory.
So far, my organization of folders look like this
currently, my backend package.json looks like:
"name" : "backend",
"main" : "server.js",
"scripts": {
"start" : "node server.js",
"backend": "nodemon server.js" ,
"frontend" : "npm run start --prefix client",
"dev": "concurrently \"npm run backend\" \"npm run frontend\""
},
...
...
"dependencies": {
"concurrently": "^5.1.0",
"cors": "^2.8.5",
"dotenv": "^8.2.0",
"express": "^4.17.1",
"mongoose": "^5.7.8",
"nodemon": "^2.0.2"
}
...
Also, my frontend package.json looks like:
"name": "client",
...
...
"dependencies": {
"bootstrap": "^4.4.1",
"react": "^16.11.0",
"react-dom": "^16.11.0",
"react-scripts": "3.2.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
...
...
What I'm trying to do here is get into the client folder, and run the package.json on that. Is it possible to do so? Or am I going about this whole idea wrong? Or is it a bad way to organize my folders and I should do it differently?
Also, I used this post:
How to organise file structure of backend and frontend in MERN
for a possible solution for this but it doesn't seem like it is working for me.