Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems when deploy to Cloudflare Pages #4

Open
akring opened this issue Jan 1, 2024 · 10 comments
Open

Problems when deploy to Cloudflare Pages #4

akring opened this issue Jan 1, 2024 · 10 comments

Comments

@akring
Copy link

akring commented Jan 1, 2024

Thank you for your great template!

I have a trouble when I tried to deploy it to Cloudflare Pages, here is my process and problems:

  1. run npx astro add cloudflare to add cloudflare support, and the astro.config.mjs is automaticaly change to:
export default defineConfig({
  ...
  output: "server",
  adapter: cloudflare(),
});
  1. run npm run build and get the following error:
> [email protected] build
> astro build

01:39:12 [WARN] [@astrojs/cloudflare] The current configuration does not support image optimization. To allow your project to build with the original, unoptimized images, the image service has been automatically switched to the 'noop' option. See https://docs.astro.build/en/reference/configuration-reference/#imageservice
01:39:12 Types generated 183ms
01:39:12 [build] output: "server"
01:39:12 [build] directory: /Users/xxx/Developer/Frontend/akring-astro-home/dist/
01:39:12 [build] adapter: @astrojs/cloudflare
01:39:12 [build] Collecting build info...
01:39:12 [build] ✓ Completed in 329ms.
01:39:12 [build] Building server entrypoints...
node:internal/fs/promises:628
  return new FileHandle(await PromisePrototypeThen(
                        ^

Error: ENOENT: no such file or directory, open '/Users/xxx/Developer/Frontend/akring-astro-home/dist/_astro/constants.x3V3ZnQq.js'
    at async open (node:internal/fs/promises:628:25)
    at async Object.readFile (node:internal/fs/promises:1228:14)
    at async extractFile (file:///Users/xxx/Developer/Frontend/akring-astro-home/node_modules/@unocss/vite/dist/index.mjs:334:20)
    at async Promise.all (index 2)
    at async setupContentExtractor (file:///Users/xxx/Developer/Frontend/akring-astro-home/node_modules/@unocss/vite/dist/index.mjs:358:5) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: '/Users/xxx/Developer/Frontend/akring-astro-home/dist/_astro/constants.x3V3ZnQq.js'
}

Wish you can help me to deploy this great template to Cloudflare.

@Ladvace
Copy link
Owner

Ladvace commented Jan 1, 2024

I'll dig into it in the next days to fix it, I saw that this is related to the astro-icon package, if you remove it, it should work

also, use pnpm and not npm, I forgot to add it to the package json

@Ladvace
Copy link
Owner

Ladvace commented Feb 3, 2024

sorry if I didn't reply, I've been busy, I'll try to fix it as soon as I have time, otherwise feel free to open a PR if you find a fix for it

@dann-5m
Copy link

dann-5m commented Apr 9, 2024

Hi, still having this issue, is there an update?

@Ladvace
Copy link
Owner

Ladvace commented Apr 10, 2024

I'm not getting this error anymore, are you using the last version (last commits)?

@dann-5m
Copy link

dann-5m commented Apr 10, 2024

Hmm builds normal, however doesn't seem to want to deploy

@Ladvace
Copy link
Owner

Ladvace commented Apr 11, 2024

could you send the build logs or the error?

@vnl
Copy link

vnl commented Jan 20, 2025

@Ladvace , I am also finding the same issue with cloudflare pages. Although thank you for sharing this project.
Here is the error:

2025-01-20T10:48:46.850125Z	Cloning repository...
2025-01-20T10:48:47.662065Z	From https://github.com/vnl/vivianlobo.dev
2025-01-20T10:48:47.662828Z	 * branch            1c77075a285c2b3d329045e8557335a79d6e9f1f -> FETCH_HEAD
2025-01-20T10:48:47.66296Z	
2025-01-20T10:48:47.715117Z	HEAD is now at 1c77075 some build cleanup
2025-01-20T10:48:47.715634Z	
2025-01-20T10:48:47.796566Z	
2025-01-20T10:48:47.797417Z	Using v2 root directory strategy
2025-01-20T10:48:47.819942Z	Success: Finished cloning repository files
2025-01-20T10:48:49.261479Z	Checking for configuration in a Wrangler configuration file (BETA)
2025-01-20T10:48:49.262436Z	
2025-01-20T10:48:49.365522Z	No wrangler.toml file found. Continuing.
2025-01-20T10:48:49.51599Z	Detected the following tools from environment: [email protected], [email protected], [email protected]
2025-01-20T10:48:50.30344Z	Installing project dependencies: pnpm install
2025-01-20T10:48:51.008668Z	 WARN  Ignoring not compatible lockfile at /opt/buildhome/repo/pnpm-lock.yaml
2025-01-20T10:48:51.211755Z	Progress: resolved 1, reused 0, downloaded 0, added 0
2025-01-20T10:48:52.212611Z	Progress: resolved 50, reused 0, downloaded 38, added 0
2025-01-20T10:48:53.214613Z	Progress: resolved 161, reused 0, downloaded 145, added 0
2025-01-20T10:48:54.215666Z	Progress: resolved 271, reused 0, downloaded 247, added 0
2025-01-20T10:48:55.257867Z	Progress: resolved 451, reused 0, downloaded 376, added 0
2025-01-20T10:48:56.259454Z	Progress: resolved 682, reused 0, downloaded 530, added 0
2025-01-20T10:48:56.274053Z	 WARN  deprecated [email protected]: This package has been deprecated and is no longer maintained. Please use @rollup/plugin-inject.
2025-01-20T10:48:56.670707Z	 WARN  deprecated [email protected]: Please use @jridgewell/sourcemap-codec instead
2025-01-20T10:48:56.870749Z	Packages: +650
2025-01-20T10:48:56.871505Z	++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2025-01-20T10:48:57.260487Z	Progress: resolved 777, reused 0, downloaded 638, added 211
2025-01-20T10:48:57.885182Z	Progress: resolved 777, reused 0, downloaded 650, added 650, done
2025-01-20T10:48:58.103378Z	.../[email protected]/node_modules/esbuild postinstall$ node install.js
2025-01-20T10:48:58.103936Z	.../[email protected]/node_modules/esbuild postinstall$ node install.js
2025-01-20T10:48:58.190697Z	.../[email protected]/node_modules/esbuild postinstall$ node install.js
2025-01-20T10:48:58.194036Z	.../[email protected]/node_modules/esbuild postinstall$ node install.js
2025-01-20T10:48:58.240114Z	.../node_modules/workerd postinstall$ node install.js
2025-01-20T10:48:58.269815Z	.../[email protected]/node_modules/esbuild postinstall: Done
2025-01-20T10:48:58.275639Z	.../[email protected]/node_modules/esbuild postinstall: Done
2025-01-20T10:48:58.333402Z	.../[email protected]/node_modules/esbuild postinstall: Done
2025-01-20T10:48:58.357031Z	.../[email protected]/node_modules/esbuild postinstall: Done
2025-01-20T10:48:58.380961Z	.../node_modules/workerd postinstall: Done
2025-01-20T10:48:58.970647Z	.../[email protected]/node_modules/sharp install$ node install/check
2025-01-20T10:48:59.108885Z	.../[email protected]/node_modules/sharp install: Done
2025-01-20T10:49:03.736665Z	
2025-01-20T10:49:03.737002Z	dependencies:
2025-01-20T10:49:03.73724Z	+ @astrojs/cloudflare 12.2.0
2025-01-20T10:49:03.737921Z	+ @astrojs/rss 4.0.11
2025-01-20T10:49:03.738094Z	+ @astrojs/sitemap 3.2.1
2025-01-20T10:49:03.738242Z	+ @astrojs/solid-js 5.0.3
2025-01-20T10:49:03.738538Z	+ @astrojs/svelte 7.0.3
2025-01-20T10:49:03.738626Z	+ @iconify-json/ri 1.2.5
2025-01-20T10:49:03.738751Z	+ @rive-app/canvas 2.25.4
2025-01-20T10:49:03.738919Z	+ astro 5.1.7
2025-01-20T10:49:03.739038Z	+ astro-icon 1.1.5
2025-01-20T10:49:03.739211Z	+ astro-robots-txt 1.0.0
2025-01-20T10:49:03.739389Z	+ d3 7.9.0
2025-01-20T10:49:03.739559Z	+ gsap 3.12.7
2025-01-20T10:49:03.739682Z	+ lenis 1.1.19
2025-01-20T10:49:03.739802Z	+ mdast-util-to-string 4.0.0
2025-01-20T10:49:03.740127Z	+ reading-time 1.5.0
2025-01-20T10:49:03.740304Z	+ solid-js 1.9.4
2025-01-20T10:49:03.740426Z	+ svelte 5.19.0
2025-01-20T10:49:03.740538Z	
2025-01-20T10:49:03.740648Z	devDependencies:
2025-01-20T10:49:03.740754Z	+ @types/d3 7.4.3
2025-01-20T10:49:03.740882Z	+ @unocss/astro 0.63.6 (65.4.2 is available)
2025-01-20T10:49:03.741002Z	+ @unocss/postcss 0.63.6 (65.4.2 is available)
2025-01-20T10:49:03.741103Z	+ @unocss/preset-uno 0.63.6 (65.4.2 is available)
2025-01-20T10:49:03.741208Z	+ @unocss/reset 0.63.6 (65.4.2 is available)
2025-01-20T10:49:03.74133Z	+ autoprefixer 10.4.20
2025-01-20T10:49:03.741456Z	+ markdown-it 14.1.0
2025-01-20T10:49:03.74156Z	+ motion 10.18.0 (11.18.1 is available)
2025-01-20T10:49:03.74166Z	+ sanitize-html 2.14.0
2025-01-20T10:49:03.741768Z	+ typescript 5.7.3
2025-01-20T10:49:03.741875Z	+ unocss 0.63.6 (65.4.2 is available)
2025-01-20T10:49:03.741979Z	
2025-01-20T10:49:03.742079Z	 WARN  Issues with peer dependencies found
2025-01-20T10:49:03.742192Z	.
2025-01-20T10:49:03.742644Z	└─┬ @astrojs/svelte 7.0.3
2025-01-20T10:49:03.742765Z	  └─┬ @sveltejs/vite-plugin-svelte 5.0.3
2025-01-20T10:49:03.742868Z	    ├── ✕ unmet peer vite@^6.0.0: found 5.4.12
2025-01-20T10:49:03.742972Z	    └─┬ @sveltejs/vite-plugin-svelte-inspector 4.0.1
2025-01-20T10:49:03.743072Z	      └── ✕ unmet peer vite@^6.0.0: found 5.4.12
2025-01-20T10:49:03.743172Z	
2025-01-20T10:49:03.74357Z	Done in 13.1s
2025-01-20T10:49:03.837643Z	Executing user command: npm run build
2025-01-20T10:49:04.598315Z	
2025-01-20T10:49:04.598553Z	> [email protected] build
2025-01-20T10:49:04.598663Z	> astro build
2025-01-20T10:49:04.598763Z	
2025-01-20T10:49:06.678065Z	�[2m10:49:06 AM�[22m �[31m�[1m[vite]�[22m�[39m �[31m�[2m(ssr)�[22m�[39m �[31mError when evaluating SSR module /opt/buildhome/repo/astro.config.mjs:
2025-01-20T10:49:06.678398Z	|- file:///opt/buildhome/repo/node_modules/.pnpm/@[email protected][email protected][email protected]/node_modules/@sveltejs/vite-plugin-svelte/src/utils/options.js:5
2025-01-20T10:49:06.678573Z		defaultClientConditions,
2025-01-20T10:49:06.678701Z		^^^^^^^^^^^^^^^^^^^^^^^
2025-01-20T10:49:06.678825Z	SyntaxError: The requested module 'vite' does not provide an export named 'defaultClientConditions'
2025-01-20T10:49:06.67896Z	    at ModuleJob._instantiate (node:internal/modules/esm/module_job:124:21)
2025-01-20T10:49:06.679054Z	    at async ModuleJob.run (node:internal/modules/esm/module_job:190:5)
2025-01-20T10:49:06.67914Z	�[39m
2025-01-20T10:49:06.679516Z	[astro] Unable to load your Astro config
2025-01-20T10:49:06.679788Z	
2025-01-20T10:49:07.003477Z	The requested module 'vite' does not provide an export named 'defaultClientConditions'
2025-01-20T10:49:07.00376Z	  Stack trace:
2025-01-20T10:49:07.003896Z	    at ModuleJob._instantiate (node:internal/modules/esm/module_job:124:21)
2025-01-20T10:49:07.118987Z	Failed: Error while executing user command. Exited with error code: 1
2025-01-20T10:49:07.131573Z	Failed: build command exited with code: 1
2025-01-20T10:49:07.824718Z	Failed: error occurred while running build command

@Ladvace
Copy link
Owner

Ladvace commented Jan 20, 2025

2025-01-20T10:49:06.678825Z SyntaxError: The requested module 'vite' does not provide an export named 'defaultClientConditions'

the seems to be a different error, can you open another issue? I'm also accept PR if you find the problem

@vnl
Copy link

vnl commented Jan 20, 2025

@Ladvace I found out the trick is to use pnpm and make sure you pay attention to the warnings.

 WARN  Issues with peer dependencies found
.
├─┬ astro 5.1.1
│ └─┬ zod-to-json-schema 3.24.1
│   └── ✕ unmet peer zod@^3.24.1: found 3.23.8
├─┬ @unocss/astro 0.63.4
│ ├── ✕ unmet peer vite@"^2.9.0 || ^3.0.0-0 || ^4.0.0 || ^5.0.0-0": found 6.0.5
│ └─┬ @unocss/vite 0.63.4
│   └── ✕ unmet peer vite@"^2.9.0 || ^3.0.0-0 || ^4.0.0 || ^5.0.0-0": found 6.0.5
└─┬ unocss 0.63.4
  └── ✕ unmet peer vite@"^2.9.0 || ^3.0.0-0 || ^4.0.0 || ^5.0.0-0": found 6.0.5

Here, the vite version mismatch is what causes Cloudflare issues.

Running this command:
pnpm install @unocss/astro@latest @unocss/vite@latest unocss@latest

I sorted those warnings, and the build just worked on pages. I will paise a PR.

@Ladvace
Copy link
Owner

Ladvace commented Jan 20, 2025

great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants