misterpoppins
misterpoppins
CDCloudflare Developers
Created by misterpoppins on 5/10/2024 in #pages-help
Wrangler deploy shows success but actually fails
No description
9 replies
CDCloudflare Developers
Created by misterpoppins on 4/29/2024 in #pages-help
ERROR: Could not resolve "crypto"
I'm using HonoJS with the library Hono Sessions. When I use wrangler to preview wrangler pages dev dist I get an error complaining about not being able to resolve crypto:
✘ [ERROR] 1 error(s) and 0 warning(s) when compiling Worker.


▲ [WARNING] Failed to bundle _worker.js. Error: Build failed with 1 error:

_worker.js:1:580: ERROR: Could not resolve "crypto"
at failureErrorWithLog (/Users/anthony/dev/breeze/node_modules/esbuild/lib/main.js:1636:15)
at /Users/anthony/dev/breeze/node_modules/esbuild/lib/main.js:1048:25
at /Users/anthony/dev/breeze/node_modules/esbuild/lib/main.js:1512:9
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
errors: [
{
detail: undefined,
id: '',
location: [Object],
notes: [Array],
pluginName: '',
text: 'Could not resolve "crypto"'
}
],
warnings: []
}
✘ [ERROR] 1 error(s) and 0 warning(s) when compiling Worker.


▲ [WARNING] Failed to bundle _worker.js. Error: Build failed with 1 error:

_worker.js:1:580: ERROR: Could not resolve "crypto"
at failureErrorWithLog (/Users/anthony/dev/breeze/node_modules/esbuild/lib/main.js:1636:15)
at /Users/anthony/dev/breeze/node_modules/esbuild/lib/main.js:1048:25
at /Users/anthony/dev/breeze/node_modules/esbuild/lib/main.js:1512:9
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
errors: [
{
detail: undefined,
id: '',
location: [Object],
notes: [Array],
pluginName: '',
text: 'Could not resolve "crypto"'
}
],
warnings: []
}
For context, I've ensured I have node compatibility enabled:
// wrangler.toml
compatibility_flags = [ "nodejs_compat" ]
// wrangler.toml
compatibility_flags = [ "nodejs_compat" ]
If I remove any imports of the Hono Sessions library my worker builds...the issue is if I go to that project and run their Cloudflare test, it works totally fine! The only thing I can think of is they are testing against Cloudflare Workers, not Pages. Is there a difference in the node APIs offered between Workers and Pages? If not, any thoughts on why this might be happening? If it matters I'm using Vite to build my project. https://github.com/jcs224/hono_sessions
4 replies