Cloudflare pages build not finding output directory

The build works, but then it can’t find the output directory. If I put the output directory into git, it is able to deploy it. This is just generating a dir called out/ that definitely has an index.html in it. Any ideas?

15:38:08.049	Initializing build environment. This may take up to a few minutes to complete
15:38:45.238	Success: Finished initializing build environment
15:38:45.238	Cloning repository...
15:38:47.427	Success: Finished cloning repository files
15:38:47.653	Installing dependencies
15:38:47.671	Python version set to 2.7
15:38:50.837	v12.18.0 is already installed.
15:38:51.188	Now using node v12.18.0 (npm v6.14.4)
15:38:51.209	Started restoring cached build plugins
15:38:51.219	Finished restoring cached build plugins
15:38:51.546	Attempting ruby version 2.7.1, read from environment
15:38:52.782	Using ruby version 2.7.1
15:38:53.091	Using PHP version 5.6
15:38:53.117	5.2 is already installed.
15:38:53.120	Using Swift version 5.2
15:38:53.121	Started restoring cached node modules
15:38:53.122	Finished restoring cached node modules
15:38:53.123	Started restoring cached yarn cache
15:38:53.125	Finished restoring cached yarn cache
15:38:53.127	Installing yarn at version 1.22.4
15:38:53.137	e[37mInstalling Yarn!e[0m
15:38:53.137	e[36m> Downloading tarball...e[0m
15:38:53.147	
15:38:53.147	[1/2]: https://yarnpkg.com/downloads/1.22.4/yarn-v1.22.4.tar.gz --> /tmp/yarn.tar.gz.VK9yVH2V4i
15:38:53.148	  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
15:38:53.148	                                 Dload  Upload   Total   Spent    Left  Speed
15:38:53.334	
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100    79  100    79    0     0    423      0 --:--:-- --:--:-- --:--:--   422
15:38:53.712	
100    93  100    93    0     0    164      0 --:--:-- --:--:-- --:--:--   164
15:38:53.967	
100   625  100   625    0     0    761      0 --:--:-- --:--:-- --:--:--   761
15:38:54.247	
 63 1215k   63  770k    0     0   726k      0  0:00:01  0:00:01 --:--:--  726k
100 1215k  100 1215k    0     0  1105k      0  0:00:01  0:00:01 --:--:-- 11.1M
15:38:54.248	
15:38:54.248	[2/2]: https://yarnpkg.com/downloads/1.22.4/yarn-v1.22.4.tar.gz.asc --> /tmp/yarn.tar.gz.VK9yVH2V4i.asc
15:38:54.295	
100    83  100    83    0     0   1735      0 --:--:-- --:--:-- --:--:--  1735
15:38:54.338	
100    97  100    97    0     0   1075      0 --:--:-- --:--:-- --:--:--  1075
15:38:54.372	
100   629  100   629    0     0   5057      0 --:--:-- --:--:-- --:--:--  5057
15:38:54.388	
100  1028  100  1028    0     0   7292      0 --:--:-- --:--:-- --:--:--  7292
15:38:54.409	e[36m> Verifying integrity...e[0m
15:38:54.506	gpg: Signature made Mon 09 Mar 2020 03:52:13 PM UTC using RSA key ID 69475BAA
15:38:54.511	gpg: Good signature from "Yarn Packaging <[email protected]>"
15:38:54.513	gpg: Note: This key has expired!
15:38:54.513	Primary key fingerprint: 72EC F46A 56B4 AD39 C907  BBB7 1646 B01B 86E5 0310
15:38:54.514	     Subkey fingerprint: 6D98 490C 6F1A CDDD 448E  4595 4F77 6793 6947 5BAA
15:38:54.514	e[32m> GPG signature looks goode[0m
15:38:54.514	e[36m> Extracting to ~/.yarn...e[0m
15:38:54.579	e[36m> Adding to $PATH...e[0m
15:38:54.592	e[36m> We've added the following to your /opt/buildhome/.bashrc
15:38:54.592	> If this isn't the profile of your current shell then please add the following to your correct profile:
15:38:54.592	   
15:38:54.592	export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH"
15:38:54.592	e[0m
15:38:54.802	e[32m> Successfully installed Yarn 1.22.4! Please open another terminal where the `yarn` command will now be available.e[0m
15:38:55.011	Installing NPM modules using Yarn version 1.22.4
15:38:55.278	yarn install v1.22.4
15:38:55.289	warning package.json: License should be a valid SPDX license expression
15:38:55.350	warning [email protected]: License should be a valid SPDX license expression
15:38:55.351	[1/4] Resolving packages...
15:38:55.714	[2/4] Fetching packages...
15:39:08.033	info @next/[email protected]: The platform "linux" is incompatible with this module.
15:39:08.033	info "@next/[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
15:39:08.034	info @next/[email protected]: The CPU architecture "x64" is incompatible with this module.
15:39:08.034	info @next/[email protected]: The platform "linux" is incompatible with this module.
15:39:08.034	info "@next/[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
15:39:08.034	info @next/[email protected]: The platform "linux" is incompatible with this module.
15:39:08.034	info "@next/[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
15:39:08.035	info [email protected]: The platform "linux" is incompatible with this module.
15:39:08.035	info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
15:39:08.045	[3/4] Linking dependencies...
15:39:08.049	warning "nextra-theme-docs > @reach/[email protected]" has incorrect peer dependency "[email protected]^16.8.0".
15:39:08.049	warning "nextra-theme-docs > @reach/[email protected]" has incorrect peer dependency "[email protected]^16.8.0".
15:39:08.049	warning "nextra-theme-docs > [email protected]" has incorrect peer dependency "[email protected]^9.5.5".
15:39:08.049	warning "nextra-theme-docs > [email protected]" has incorrect peer dependency "[email protected]^16.13.1".
15:39:08.049	warning "nextra-theme-docs > [email protected]" has incorrect peer dependency "[email protected]^16.13.1".
15:39:08.049	warning "nextra-theme-docs > [email protected]" has unmet peer dependency "@types/[email protected]>=0.0.0 <=99".
15:39:08.050	warning "nextra-theme-docs > @reach/skip-nav > @reach/[email protected]" has incorrect peer dependency "[email protected]^16.8.0".
15:39:08.050	warning "nextra-theme-docs > @reach/skip-nav > @reach/[email protected]" has incorrect peer dependency "[email protected]^16.8.0".
15:39:08.050	warning " > [email protected]" has unmet peer dependency "[email protected]>= 16.8.0".
15:39:08.051	warning " > @compiled/[email protected]" has unmet peer dependency "[email protected]>= 4.46.0".
15:39:08.052	warning "@switz/eslint-config > @typescript-eslint/eslint-plugin > [email protected]" has unmet peer dependency "[email protected]>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta".
15:39:16.160	[4/4] Building fresh packages...
15:39:16.179	Done in 20.90s.
15:39:16.196	NPM modules installed using Yarn
15:39:16.313	warning package.json: License should be a valid SPDX license expression
15:39:16.908	Installing Hugo 0.54.0
15:39:20.692	Hugo Static Site Generator v0.54.0-B1A82C61A/extended linux/amd64 BuildDate: 2019-02-01T10:04:38Z
15:39:20.693	Started restoring cached go cache
15:39:20.695	Finished restoring cached go cache
15:39:21.113	go version go1.14.4 linux/amd64
15:39:21.117	go version go1.14.4 linux/amd64
15:39:21.124	Installing missing commands
15:39:21.124	Verify run directory
15:39:21.124	Executing user command: next build
15:39:21.877	info  - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5
15:39:22.088	warn  - You have enabled experimental feature(s).
15:39:22.088	warn  - Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use them at your own risk.
15:39:22.088	
15:39:22.090	warn  - No build cache found. Please configure build caching for faster rebuilds. Read more: https://nextjs.org/docs/messages/no-cache
15:39:22.222	Attention: Next.js now collects completely anonymous telemetry regarding usage.
15:39:22.222	This information is used to shape Next.js' roadmap and prioritize features.
15:39:22.222	You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
15:39:22.222	https://nextjs.org/telemetry
15:39:22.222	
15:39:22.339	info  - Checking validity of types...
15:39:22.343	info  - Creating an optimized production build...
15:39:22.917	info  - Using external babel configuration from /opt/buildhome/repo/.babelrc
15:39:48.625	info  - Compiled successfully
15:39:48.626	info  - Collecting page data...
15:39:49.173	info  - Generating static pages (0/7)
15:39:49.439	info  - Generating static pages (1/7)
15:39:49.717	info  - Generating static pages (3/7)
15:39:49.724	info  - Generating static pages (5/7)
15:39:49.729	info  - Generating static pages (7/7)
15:39:49.842	info  - Finalizing page optimization...
15:39:49.845	
15:39:49.852	Page                              Size     First Load JS
15:39:49.852	┌ ○ /                             4.64 kB         152 kB
15:39:49.852	├   /_app                         0 B            89.9 kB
15:39:49.852	├ ○ /404                          195 B          90.1 kB
15:39:49.852	+ First Load JS shared by all     89.9 kB
15:39:49.852	  ├ chunks/framework.925f8b.js    42 kB
15:39:49.852	  ├ chunks/main.40f761.js         23.6 kB
15:39:49.852	  ├ chunks/pages/_app.9fa889.js   22.7 kB
15:39:49.852	  ├ chunks/webpack.647b91.js      1.52 kB
15:39:49.852	  └ css/4511c784e81900b89149.css  34.6 kB
15:39:49.852	
15:39:49.852	λ  (Server)  server-side renders at runtime (uses getInitialProps or getServerSideProps)
15:39:49.852	○  (Static)  automatically rendered as static HTML (uses no initial props)
15:39:49.852	●  (SSG)     automatically generated as static HTML + JSON (uses getStaticProps)
15:39:49.852	   (ISR)     incremental static regeneration (uses revalidate in getStaticProps)
15:39:49.852	
15:39:50.082	Finished
15:39:50.082	Validating asset output directory
15:39:50.492	Deploying your site to Cloudflare's global network...
15:39:50.693	Failed: build output directory not found```

I see you run next build but not next export. AFAIK you need the export for the out directory to actually be made.

My build step includes both:

    "build": "NODE_ENV=production node bin/rss.js && next build && next export",

You’re not running npm build though, you’re using next build

Executing user command: next build

Well… this is embarrassing. Thank you for pointing that out, my mistake.

Haha all good, everyone makes silly mistakes.
If you ever need more support in the future, the Discord server is a quick way to get it (or just chat with everyone): https://workers.community

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.