Skip to content

Fix Render deploy: add .js extensions to ES module imports#23

Merged
mahata merged 3 commits intomainfrom
copilot/fix-22
Jul 9, 2025
Merged

Fix Render deploy: add .js extensions to ES module imports#23
mahata merged 3 commits intomainfrom
copilot/fix-22

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jul 9, 2025

This PR fixes the Render deployment issue where the service fails to start with ERR_MODULE_NOT_FOUND errors.

Problem

The deployment was failing with:

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/opt/render/project/src/dist/hono/app' imported from /opt/render/project/src/dist/hono/index.js

Root Cause

When using ES modules ("type": "module" in package.json), Node.js requires explicit file extensions for relative imports. The TypeScript source files were using imports like:

import { app, injectWebSocket } from "./app";

But Node.js needs:

import { app, injectWebSocket } from "./app.js";

Solution

Updated all relative imports in TypeScript files to include explicit .js extensions:

  • hono/index.ts: "./app""./app.js"
  • hono/app.tsx: Updated all route imports to use .js extensions
  • hono/routes/index.tsx: "../components/ChatPage""../components/ChatPage.js"
  • All test files updated for consistency

Changes Made

  • ✅ Fixed 9 TypeScript files with relative imports
  • ✅ Added deployment test to validate ES module compatibility
  • ✅ No changes needed to package.json or render.yaml

Validation

  • Build completes successfully: pnpm run build
  • Production server starts without errors: pnpm run start:prod
  • All endpoints work correctly (health check, main page) ✅
  • All existing tests continue to pass ✅
  • New deployment tests validate import resolution ✅

The service now starts successfully and is ready for Render deployment.

Fixes #22.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: mahata <23497+mahata@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix Render deploy: ensure 'dist/hono/app' is built and available to avoid ERR_MODULE_NOT_FOUND Fix Render deploy: add .js extensions to ES module imports Jul 9, 2025
Copilot AI requested a review from mahata July 9, 2025 09:54
Copilot finished work on behalf of mahata July 9, 2025 09:54
@mahata
Copy link
Copy Markdown
Owner

mahata commented Jul 9, 2025

@copilot Fix CI in GitHub Actions.

Co-authored-by: mahata <23497+mahata@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jul 9, 2025

@copilot Fix CI in GitHub Actions.

Fixed the CI issue - it was a Biome linting error due to a missing newline at the end of the deployment.test.ts file. All CI steps now pass: tests ✅, linting ✅, build ✅. Commit 622c273

Copilot finished work on behalf of mahata July 9, 2025 10:01
@mahata mahata marked this pull request as ready for review July 9, 2025 12:59
@mahata mahata merged commit ef9c1f8 into main Jul 9, 2025
1 check passed
@mahata mahata deleted the copilot/fix-22 branch July 9, 2025 13:01
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

Successfully merging this pull request may close these issues.

Fix Render deploy: ensure 'dist/hono/app' is built and available to avoid ERR_MODULE_NOT_FOUND

2 participants