Npm Run Build Failed

Hi There,
I am deploying my app and the build failed with the following error.

Dec 1 04:26:47 PM ==> Cloning from https://github.com/Kelvonetics/workout-expense-tracker
Dec 1 04:26:48 PM ==> Checking out commit 8b5e18d1120fbadd482cb5cc0baea332992aad26 in branch main
Dec 1 04:26:51 PM ==> Downloading cache…
Dec 1 04:26:59 PM ==> Transferred 2.9KB in 7s. Extraction took 0s.
Dec 1 04:27:01 PM ==> Running build command ‘npm run build’…
Dec 1 04:27:01 PM npm ERR! code ENOENT
Dec 1 04:27:01 PM npm ERR! syscall open
Dec 1 04:27:01 PM npm ERR! path /opt/render/project/src/package.json
Dec 1 04:27:01 PM npm ERR! errno -2
Dec 1 04:27:01 PM npm ERR! enoent ENOENT: no such file or directory, open ‘/opt/render/project/src/package.json’
Dec 1 04:27:01 PM npm ERR! enoent This is related to npm not being able to find a file.
Dec 1 04:27:01 PM npm ERR! enoent
Dec 1 04:27:01 PM
Dec 1 04:27:01 PM npm ERR! A complete log of this run can be found in:
Dec 1 04:27:01 PM npm ERR! /opt/render/.cache/_logs/2022-12-01T15_27_01_498Z-debug.log
Dec 1 04:27:01 PM ==> Build failed :disappointed:
Dec 1 04:27:01 PM ==> Generating container image from build. This may take a few minutes…

Any idea or help will be appreciated.

Hi there,

I think I replied to a chat you also opened.

The crux of the error here is:

no such file or directory, open ‘/opt/render/project/src/package.json’

You’ll need to ensure you have a package.json in the root of your repo, or update the “Root Directory” in the service settings (or commands themselves) to run in the folder where you keep that file.

Kind regards

Alan

Thanks, Alan, I provided the package.json on my root folder and it built successfully, my mistake.
Now on the URL: https://workout-expense-app.onrender.com/ I get cannot get /
Still looking into it though.
Thanks once again

Hi,
Error: ENOENT: no such file or directory, stat ‘/opt/render/project/src/server/client/build/index.html’
So after further checking, I noticed the directory structure is trying to locate the index.html file through server/client which should not be so.
Any prompt response will be highly appreciated.

That would point to an issue in your code referencing an incorrect path, you would need to identify and update it.

Alan

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.