Support Forums

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

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

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!

Sorry to revive a year old thread, but I seem to be having the same issue with a directory also named “static”. I’m not sure if its a coincidence but it seems weird to have this same issue twice. I can confirm that cloning the repo also clones the nonempty static directory. Webpack complains about not being able to locate the static directory.

10:49:07 PM: ⚠ 「copy-webpack-plugin」: unable to locate 'static/' at '/opt/build/repo/static'

Additionally, it seems like its not able to find certain npm packages that definitely get installed on my machine, even after a fresh git clone:

10:49:07 PM: Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js):
10:49:07 PM: ModuleBuildError: Module build failed: Error: ENOENT: no such file or directory, open '/opt/build/repo/node_modules/css-loader/dist/runtime/api.js'
10:49:07 PM:     at runLoaders (/opt/build/repo/node_modules/webpack/lib/NormalModule.js:316:20)
10:49:07 PM:     at /opt/build/repo/node_modules/loader-runner/lib/LoaderRunner.js:367:11
10:49:07 PM:     at Array.<anonymous> (/opt/build/repo/node_modules/loader-runner/lib/LoaderRunner.js:203:19)
10:49:07 PM:     at Storage.finished (/opt/build/repo/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:55:16)
10:49:07 PM:     at ReadFileContext.provider (/opt/build/repo/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:91:9)
10:49:07 PM:     at ReadFileContext.callback (/opt/build/repo/node_modules/graceful-fs/graceful-fs.js:115:16)
10:49:07 PM:     at FSReqWrap.readFileAfterOpen [as oncomplete] (fs.js:237:13)
10:49:07 PM:  @ ./src/index.tsx 4:0-34

What happens if you throw a .gitkeep in the directory?

I’m having the same problem using parcel-plugin-static-files-copy. Everything works perfect during development, but fails when building from Github. It makes me think on some configuration I’m missing?

have you ruled out case? :thinking:

Thanks for your answer. This cannot be the issue, all my files are in lowercase. I’ve just opened another topic to not pollute this one with my own problem.