Deployment fails – can't find files in folder that's added to git

Briefly summarize the issues you have been experiencing.

I have a site that is built by the npm run build command, using Parcel. The original setup was easy as I only have to run the same command on Netlify. It builds the site into the dist folder and serves the files from there.

However, I realized I need to add a robots.txt and sitemap.xml to the build output. I’ve found parcel-plugin-robot that does that and it builds the site correctly on my computer. Those two files need to be placed in the static folder.

However, when I deploy to Netlify it runs into the following error:

5:09:14 PM: export GOROOT='/opt/buildhome/.gimme/versions/go1.12.linux.amd64';
5:09:14 PM: export PATH="/opt/buildhome/.gimme/versions/go1.12.linux.amd64/bin:${PATH}";
5:09:14 PM: go version >&2;
5:09:14 PM: export GIMME_ENV='/opt/buildhome/.gimme/env/go1.12.linux.amd64.env';
5:09:14 PM: go version go1.12 linux/amd64
5:09:14 PM: Installing missing commands
5:09:14 PM: Verify run directory
5:09:14 PM: Executing user command: npm run build
5:09:14 PM: > balinterdi.com@1.0.0 build /opt/build/repo
5:09:14 PM: > parcel build index.html
5:09:15 PM:   Copy plugin error:  ENOENT: no such file or directory, copyfile '/opt/build/repo/static/robots.txt' -> '/opt/build/repo/dist/robots.txt'
5:09:15 PM:   Copy plugin error:  ENOENT: no such file or directory, copyfile '/opt/build/repo/static/sitemap.xml' -> '/opt/build/repo/dist/sitemap.xml'
5:09:27 PM: ✨  Built in 12.57s.

Please provide a link to your live site hosted on Netlify

https://www.emberjs-code-review.com/

What have you tried as far as troubleshooting goes? Do you have an idea what is causing the problem?

I tried to run the deploy again but I got the same error. I think the problem might be that the static folder is not present on Netlify. I’ve verified that the folder and the two files are added to the git repo:

$ git ls-files static                                                                                                                                                            master 41ee1f5
static/robots.txt
static/sitemap.xml

Do you have any other information that is relevant, such as links to docs, libraries, or other resources?

Hey there, is the static directory empty and the robots.txt and sitemap.xml generated by your build process? or the files in the static directory already when you check them into your build? If you clone your repo into a fresh directory, do you see them there?

Hey Gerald,

Thank you for your response.

The files are there in the repository and are not generated by the build process.

In the meantime, I also followed the steps described for building the image locally (described here) and it failed with the same error message even though the files were also there in that case (in the local Docker image).

Could you add a step to your build script in package.json? Something like an ls -l static/ step just before parcel runs to ensure that the build process isn’t somehow removing the files? Some SSG’s like Jekyll are prone to scooting files around unexpectedly…

Thank you for your answer.

I did what you suggested and I can confirm the files were there:

10:55:19 AM: dist/index.html                              10.27 KB    3.71s
10:55:19 AM: dist/avatar-balint.b1e8b9b3.jpg               8.85 KB    2.33s
10:55:19 AM: dist/font.2f561455.css.map                    2.54 KB      0ms
10:55:19 AM: dist/font.2f561455.css                        1.17 KB    7.66s
10:55:19 AM: dist/checkmarks.fd10245c.svg                  1.16 KB    2.80s
10:55:19 AM: dist/burger-menu.03e94272.svg                 1.08 KB    2.33s
10:55:19 AM: total 8
10:55:19 AM: -rw-r--r-- 1 buildbot root  80 Jun 11 08:54 robots.txt
10:55:19 AM: -rw-r--r-- 1 buildbot root 497 Jun 11 08:54 sitemap.xml
10:55:19 AM: Skipping functions preparation step: no functions directory set
10:55:19 AM: Caching artifacts

As I couldn’t find the source code for the parcel-plugin-robot npm package which could shed some light on what was wrong, I ended up writing a node script manually that first calls the parcel build command and then copies the files via fs.copyFileSync.

This works now.

1 Like

thanks for closing the loop and letting us know!