Skip to content

[BUG] Error Could not resolve when npm run deploy #661

Closed
@ton11797

Description

@ton11797

Describe the bug

Error when try to run npm run deploy

Next.js version : 15.3.1
@opennextjs/cloudflare version: 1.0.2
@opennextjs/aws version: ^3.6.1

┌─────────────────────────────────┐
│ OpenNext — Building Next.js app │
└─────────────────────────────────┘


> cf-bug@0.1.0 build
> next build

Using vars defined in .dev.vars
   ▲ Next.js 15.3.1
   - Environments: .env

Using vars defined in .dev.vars
   Creating an optimized production build ...
Using vars defined in .dev.vars
Using vars defined in .dev.vars
Using vars defined in .dev.vars
 ✓ Compiled successfully in 0ms
 ✓ Linting and checking validity of types    
 ✓ Collecting page data    
 ✓ Generating static pages (6/6)
 ✓ Collecting build traces    
 ✓ Finalizing page optimization    

Route (app)                                 Size  First Load JS
┌ ○ /                                    5.63 kB         107 kB
├ ○ /_not-found                            977 B         102 kB
└ ƒ /test                                  136 B         101 kB
+ First Load JS shared by all             101 kB
  ├ chunks/4bd1b696-67ee12fb04071d3b.js  53.2 kB
  ├ chunks/684-71b0b1461a73105d.js       45.9 kB
  └ other shared chunks (total)          1.96 kB


○  (Static)   prerendered as static content
ƒ  (Dynamic)  server-rendered on demand


┌──────────────────────────────┐
│ OpenNext — Generating bundle │
└──────────────────────────────┘

Bundling middleware function...
Bundling static assets...
Bundling cache assets...
Building server function: default...
Applying code patches: 3.695s
# copyPackageTemplateFiles
⚙️ Bundling the OpenNext server...

X [ERROR] Could not resolve "@libsql/isomorphic-ws"

    .open-next/server-functions/default/node_modules/@libsql/hrana-client/lib-esm/index.js:1:26:
      1 │ import { WebSocket } from "@libsql/isomorphic-ws";
        ╵                           ~~~~~~~~~~~~~~~~~~~~~~~

  The module "./web.mjs" was not found on the file system:

    .open-next/server-functions/default/node_modules/@libsql/isomorphic-ws/package.json:24:19:
      24 │         "workerd": "./web.mjs",
         ╵                    ~~~~~~~~~~~

  You can mark the path "@libsql/isomorphic-ws" as external to exclude it from the bundle, which
  will remove this error and leave the unresolved path in the bundle.

C:\Users\Denice\Documents\git\cf-bug\node_modules\esbuild\lib\main.js:1463
  let error = new Error(text);
              ^

Error: Build failed with 1 error:
.open-next/server-functions/default/node_modules/@libsql/hrana-client/lib-esm/index.js:1:26: ERROR: Could not resolve "@libsql/isomorphic-ws"
    at failureErrorWithLog (C:\Users\Denice\Documents\git\cf-bug\node_modules\esbuild\lib\main.js:1463:15)
    at C:\Users\Denice\Documents\git\cf-bug\node_modules\esbuild\lib\main.js:924:25
    at runOnEndCallbacks (C:\Users\Denice\Documents\git\cf-bug\node_modules\esbuild\lib\main.js:1303:45)
    at buildResponseToResult (C:\Users\Denice\Documents\git\cf-bug\node_modules\esbuild\lib\main.js:922:7)
    at C:\Users\Denice\Documents\git\cf-bug\node_modules\esbuild\lib\main.js:949:16
    at responseCallbacks.<computed> (C:\Users\Denice\Documents\git\cf-bug\node_modules\esbuild\lib\main.js:601:9)
    at handleIncomingPacket (C:\Users\Denice\Documents\git\cf-bug\node_modules\esbuild\lib\main.js:656:12)
    at Socket.readFromStdout (C:\Users\Denice\Documents\git\cf-bug\node_modules\esbuild\lib\main.js:579:7)
    at Socket.emit (node:events:524:28)
    at Socket.emit (node:domain:489:12) {
  errors: [Getter/Setter],
  warnings: [Getter/Setter]
}

Node.js v22.13.1

Steps to reproduce

  1. npm create cloudflare@latest -- my-next-app --framework=next <---- all default
  2. setup basic drizzle with libsql
  3. simple route to call get data from db
  4. npm run deploy

Expected behavior

Able to build and deploy

@opennextjs/cloudflare version

1.0.2

Wrangler version

4.14.4

next info output

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 11 Pro
  Available memory (MB): 130199
  Available CPU cores: 24
Binaries:
  Node: 22.13.1
  npm: 10.9.2
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 15.3.1 // There is a newer version (15.3.2) available, upgrade recommended!
  eslint-config-next: 15.3.1
  react: 19.1.0
  react-dom: 19.1.0
  typescript: 5.8.3
Next.js Config:
  output: N/A
 ⚠ There is a newer version (15.3.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

Fix by change @opennextjs/cloudflare version to 1.0.0-beta.4

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions