This repo only has a single file named README.md. The use of npm run requires that there be a package.json file in this repository. Because this file is missing the npm command returns this error:
3:24:03 PM: $ npm run docs:build
3:24:03 PM: npm ERR! code ENOENT
3:24:03 PM: npm ERR! syscall open
3:24:03 PM: npm ERR! path /opt/build/repo/package.json
3:24:03 PM: npm ERR! errno -2
3:24:03 PM: npm ERR! enoent ENOENT: no such file or directory, open '/opt/build/repo/package.json'
3:24:03 PM: npm ERR! enoent This is related to npm not being able to find a file.
3:24:03 PM: npm ERR! enoent
3:24:03 PM: npm ERR! A complete log of this run can be found in:
3:24:03 PM: npm ERR! /opt/buildhome/.npm/_logs/2020-11-24T23_24_03_709Z-debug.log
The error above is npm saying in other words, “I cannot find your package.json file.” This is the log line which says that (again, using other words):
3:24:03 PM: npm ERR! enoent ENOENT: no such file or directory, open '/opt/build/repo/package.json'
Do you have a package.json locally? If so, you will need to commit that file (and many other files) to this repository before the builds will be successful using this repo.
If there are other questions or concerns, please let us know.
Many thanks @luke - this is the best response I ever encountered. It’s informative and complete. My case is slightly more complicated than simply forgetting to create the package.json file, somehow Git created two branches of the repo, and the build process fetched the wrong one.
Hi, @adriatic. There is a site setting to chose which branch to use for a site’s repository. A site can even build all branches for a repo (or just some subset of branches that you select). One branch is always the “production” branch and the other branches make “branch deploys” versions of the site where the branch name is prefixed to the site subdomain with two dashes (--) between them.
For example, if the branch is staging and the site subdomain is example then the branch deploy URL would be https://staging--example.netlify.app/.
Thank you for letting me know my response was helpful and I’m glad to learn it was something as simple as the wrong branch being used by default.
Thank you for telling me how Netlify “handles” multiple branches. My initial approach was silly - trying to follow a two years old tutorial describing the deployment process to Netlify - information that has changed a lot (for better). I will now follow your official guide to relearn Netlify deployment correctly