Core-js postinstall issue on monorepo

I deployed a mern stack full stack app to render but it’s creating an infinite loop after running my build script. Here’s my repo link. And here’s the log with the error:

Sep 18 10:36:30 AM  ==> Cloning from https://github.com/raulbarriga/MERN-FullStack-Ecommerce...
Sep 18 10:36:30 AM  ==> Checking out commit 5c91aaf70e38148bbb9b5ab6a6346069375ce62c in branch main
Sep 18 10:36:34 AM  ==> Using Node version 14.21.3 via /opt/render/project/src/package.json
Sep 18 10:36:34 AM  ==> Docs on specifying a Node version: https://render.com/docs/node-version
Sep 18 10:36:35 AM  ==> Running build command 'npm run build'...
Sep 18 10:36:36 AM  
Sep 18 10:36:36 AM  > proshop@1.0.0 build /opt/render/project/src
Sep 18 10:36:36 AM  > npm install && npm install --prefix frontend && npm run build --prefix frontend
Sep 18 10:36:36 AM  
Sep 18 10:36:45 AM  
Sep 18 10:36:45 AM  > core-js@3.32.2 postinstall /opt/render/project/src/node_modules/core-js
Sep 18 10:36:45 AM  > node -e "try{require('./postinstall')}catch(e){}"
Sep 18 10:36:45 AM  
Sep 18 10:36:46 AM  
Sep 18 10:36:46 AM  > proshop@1.0.0 install /opt/render/project/src
Sep 18 10:36:46 AM  > npm install && cd frontend && npm install
Sep 18 10:36:46 AM  
Sep 18 10:36:48 AM  
Sep 18 10:36:48 AM  > proshop@1.0.0 install /opt/render/project/src
Sep 18 10:36:48 AM  > npm install && cd frontend && npm install
Sep 18 10:36:48 AM  
Sep 18 10:36:50 AM  
Sep 18 10:36:50 AM  > proshop@1.0.0 install /opt/render/project/src
Sep 18 10:36:50 AM  > npm install && cd frontend && npm install
// infinite loops continues

The log just conitnues to repeat itself with:

> proshop@1.0.0 install /opt/render/project/src
> npm install && cd frontend && npm install

It appears there’s an error towards the top of the log that says:

> core-js@3.32.2 postinstall /opt/render/project/src/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"

Any suggestions?

Hey,

From your repo, I noticed you’re using a single package.json file for both your frontend and backend directories. It’s generally advisable to separate these projects with distinct dependencies and build/start commands.

Can you successfully build and start this project on your local machine? There are some unusual configurations in the repo, particularly in the ‘package.json’ file.

Jérémy.
Render Support, UTC+3

I have a package.json on the root of the project, next to the frontend & backend folders. I also have a package.json file inside the frontend folder (created with create-react-app).

I actually just tested it locally & it’s giving the same issue with core-js@3.32.2 postinstall & an infinite loop of running the build script. I use a NODE_ENV variable which I set to “production” so I could use the build folder of the react frontend. The loop doesn’t even go into the frontend part of the build script since the loop begins from the backend package installations (where core-js will be at).

I actually already solved it. Don’t know what it was but I changed my build script to this:
"build": "npm install && npm install --prefix frontend && npm run build --prefix frontend" and it worked.

I did first test my setup script though: "setup": "npm install && npm install --prefix frontend" and when this one worked, I again ran the build script and then it started working as expected.

Now my site’s deployed!