I cannot deploy my website

So, I was trying to deploy my website using Cloudflare, I used VS Code and React, and I am new to web development and coding in VS Code in general. Any help is appreciated, this is the log:

20:18:10.440 npm ERR! code ENOENT
20:18:10.441 npm ERR! syscall open
20:18:10.441 npm ERR! path /opt/buildhome/repo/package.json
20:18:10.442 npm ERR! errno -2
20:18:10.443 npm ERR! enoent ENOENT: no such file or directory, open ‘/opt/buildhome/repo/package.json’
20:18:10.444 npm ERR! enoent This is related to npm not being able to find a file.
20:18:10.444 npm ERR! enoent
20:18:10.446
20:18:10.446 npm ERR! A complete log of this run can be found in:
20:18:10.446 npm ERR! /opt/buildhome/.npm/_logs/2023-07-22T18_18_10_394Z-debug-0.log
20:18:10.454 Failed: Error while executing user command. Exited with error code: 254
20:18:10.461 Failed: build command exited with code: 1
20:18:11.468 Failed: error occurred while running build command

Do you have a package.json file in your project? What is your build command set to?

2 Likes

It is set to npm run build and package.json is in my project, but I do not understand how it was not found.
I do not really know how it works.

Is the package.json at the root of the repository @powerofword33? Are you able to share the repository you are deploying from?

[https://github.com/RasTixx/My-website]

can you reach it?

You’ll need to make the repository public.

ok, I changed it, it should work

[https://github.com/RasTixx/My-website.git]

With the current repository configuration, you need to set the root directory to my-website as that is the directory the project is in.

It appears there is no mention of root directory in the pages build configuration documentation anywhere @Erisa. A slight oversight I feel.

1 Like

And how can I set it there with git bash, terminal or directly through the github?

You need to set it in the pages build configuration

Under Settings > Builds & deployments > Build configurations of the pages project.

1 Like

Thank you, I think you solved it, but there is this now:

11:35:31.301 npm ERR! code EUSAGE
11:35:31.305 npm ERR!
11:35:31.306 npm ERR! npm ci can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync. Please update your lock file with npm install before continuing.
11:35:31.306 npm ERR!
11:35:31.306 npm ERR! Invalid: lock file’s [email protected] does not satisfy [email protected]
11:35:31.306 npm ERR!
11:35:31.306 npm ERR! Clean install a project
11:35:31.306 npm ERR!
11:35:31.307 npm ERR! Usage:
11:35:31.307 npm ERR! npm ci
11:35:31.307 npm ERR!
11:35:31.307 npm ERR! Options:
11:35:31.307 npm ERR! [-S
11:35:31.307 npm ERR! [-E
11:35:31.307 npm ERR! [–install-strategy <hoisted
11:35:31.308 npm ERR! [–global-style] [–omit <dev
11:35:31.308 npm ERR! [–strict-peer-deps] [–no-package-lock] [–foreground-scripts]
11:35:31.308 npm ERR! [–ignore-scripts] [–no-audit] [–no-bin-links] [–no-fund] [–dry-run]
11:35:31.308 npm ERR! [-w
11:35:31.308 npm ERR! [-ws
11:35:31.308 npm ERR!
11:35:31.309 npm ERR! aliases: clean-install, ic, install-clean, isntall-clean
11:35:31.309 npm ERR!
11:35:31.309 npm ERR! Run npm help ci for more info
11:35:31.309
11:35:31.310 npm ERR! A complete log of this run can be found in:
11:35:31.310 npm ERR! /opt/buildhome/.npm/_logs/2023-07-24T09_35_29_915Z-debug-0.log
11:35:31.321 Error: Exit with error code: 1
11:35:31.321 at ChildProcess. (/snapshot/dist/run-build.js)
11:35:31.322 at Object.onceWrapper (node:events:652:26)
11:35:31.322 at ChildProcess.emit (node:events:537:28)
11:35:31.322 at ChildProcess._handle.onexit (node:internal/child_process:291:12)
11:35:31.330 Failed: build command exited with code: 1
11:35:32.148 Failed: error occurred while running build command

Appears there is an issue with the package-lock.json. You can generate a fresh version using npm i --package-lock-only (see docs) or remove it from the remote repository.

1 Like

Do I have to update my git repository?

Because it does not seem to work.

Yes. Run the command locally, commit, and push.

So run the npm i --package-lock-only command in terminal and then in git bash those two (commit and push)?

Sorry for asking so much, I just feel like I am in a new world.

That is correct.

Something like…

npm i --package-lock-only
git add package-lock.json
git commit -m 'Regenerate package-lock.json'
git push
1 Like

Still the same error, do you have any other ideas?

You put the newly generated package-lock.json at the root of the repository rather than in the my-website directory. Thus the old one wasn’t overwritten.

1 Like