Conversation
…lare When module.createRequire() receives a directory path, Node.js treats it as a filename and starts module resolution from the parent directory. This caused getLocalWorkerdCompatibilityDate() to fail to find miniflare in the project's node_modules, falling back to a hardcoded date. Fix by appending 'package.json' to the project path, ensuring module resolution starts from the correct directory. Fixes #12155
🦋 Changeset detectedLatest commit: c41e7df The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
create-cloudflare
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-shared
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-pool-workers
@cloudflare/workers-editor-shared
@cloudflare/workers-utils
wrangler
commit: |
|
I just tried using the preview version: pnpx https://pkg.pr.new/create-cloudflare@12156 --no-auto-updateBut I still see: |
|
I don't think this is the correct fix for create-cloudflare. I think this bug was introduced by #11620 (cc @dario-piotrowicz), where the logic changed from hitting the npm registry to looking for a local copy. I suspect that we are just not able to find a local copy using require but I don't know why yet. |
|
OK so I built it locally and ran it via a direct path to the cli.js file and indeed that does seem to fix it. |
Fixes #12155.
When running
npm create cloudflare@latest, the compatibility date detection was failing and falling back to a hardcoded date (2025-09-27) instead of using the current workerd compatibility date.Root Cause:
module.createRequire()was being called with a directory path (e.g.,/path/to/project). Node.js treats this as a filename at that location and starts module resolution from the parent directory (/path/to). This causedgetLocalWorkerdCompatibilityDate()to fail to findminiflarein the project'snode_modules.Fix: Append
package.jsonto the project path when callingcreateRequire(), ensuring module resolution starts from the correct directory.Example output:
^ correct compat date — versus #12155 shows wrong compat date