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:
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?
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…
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.
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
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?
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.