Describe the bug
While building Storybook in a project that depends on @opennextjs/cloudflare, I see the following warning:
WARN unable to find package.json for @opennextjs/cloudflare
The package is installed and node_modules/@opennextjs/cloudflare/package.json does exist.
After looking into it, this seems related to how the package exports map handles subpaths. In my environment:
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
console.log(require.resolve('@opennextjs/cloudflare/package.json'));
fails before patching, but resolves successfully after locally adding an explicit ./package.json entry to the package exports.
I may be missing some intended behavior here, but it looks like tooling that inspects dependency metadata can treat package.json as unresolved because the wildcard export catches that subpath.
Steps to reproduce
- Create a project that depends on
@opennextjs/cloudflare
- Add Storybook (I reproduced this with
@storybook/nextjs-vite)
- Run
storybook build
- Observe the warning:
WARN unable to find package.json for @opennextjs/cloudflare
I could also reproduce the underlying resolution issue directly with:
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
console.log(require.resolve('@opennextjs/cloudflare/package.json'));
Expected behavior
I would expect @opennextjs/cloudflare/package.json to either:
- resolve to the actual package metadata file, or
- be explicitly handled in a way that does not make ecosystem tooling think the file is missing
@opennextjs/cloudflare version
1.18.0
Wrangler version
4.77.0
next info output
/bin/sh: yarn: command not found
/bin/sh: pnpm: command not found
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 25.3.0: Wed Jan 28 20:56:42 PST 2026; root:xnu-12377.91.3~2/RELEASE_ARM64_T8142
Available memory (MB): 32768
Available CPU cores: 10
Binaries:
Node: 24.12.0
npm: 11.6.2
Yarn: N/A
pnpm: N/A
Relevant Packages:
next: 16.2.1 // There is a newer version (16.2.2) available, upgrade recommended!
eslint-config-next: N/A
react: 19.2.4
react-dom: 19.2.4
typescript: 5.3.3
Next.js Config:
output: N/A
⚠ There is a newer version (16.2.2) available, upgrade recommended!
Please try the latest canary version (`npm install next@canary`) to confirm the issue still exists before creating a new issue.
Read more - https://nextjs.org/docs/messages/opening-an-issue
Additional context
The relevant part of the current package metadata appears to be:
"exports": {
".": {
"import": "./dist/api/index.js",
"types": "./dist/api/index.d.ts",
"default": "./dist/api/index.js"
},
"./*": {
"import": "./dist/api/*.js",
"types": "./dist/api/*.d.ts",
"default": "./dist/api/*.js"
}
}
As a local workaround, I tested adding:
"./package.json": "./package.json"
to the exports map, and that made require.resolve('@opennextjs/cloudflare/package.json') succeed and removed the Storybook warning in my project.
I am not sure whether the preferred upstream fix would be explicitly exporting ./package.json or handling that subpath another way, but I wanted to report the behavior in case it is useful. If this seems like the right direction, I can also open a PR.
Describe the bug
While building Storybook in a project that depends on
@opennextjs/cloudflare, I see the following warning:The package is installed and
node_modules/@opennextjs/cloudflare/package.jsondoes exist.After looking into it, this seems related to how the package
exportsmap handles subpaths. In my environment:fails before patching, but resolves successfully after locally adding an explicit
./package.jsonentry to the packageexports.I may be missing some intended behavior here, but it looks like tooling that inspects dependency metadata can treat
package.jsonas unresolved because the wildcard export catches that subpath.Steps to reproduce
@opennextjs/cloudflare@storybook/nextjs-vite)storybook buildI could also reproduce the underlying resolution issue directly with:
Expected behavior
I would expect
@opennextjs/cloudflare/package.jsonto either:@opennextjs/cloudflare version
1.18.0
Wrangler version
4.77.0
next info output
Additional context
The relevant part of the current package metadata appears to be:
As a local workaround, I tested adding:
to the
exportsmap, and that maderequire.resolve('@opennextjs/cloudflare/package.json')succeed and removed the Storybook warning in my project.I am not sure whether the preferred upstream fix would be explicitly exporting
./package.jsonor handling that subpath another way, but I wanted to report the behavior in case it is useful. If this seems like the right direction, I can also open a PR.