denoland / denoland/deploy_feedback

[Bug]: Vite library fails to work on Deno Deploy

Open
#888 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
79
Forks
5
PR merge metrics
No merged PRs in 30d

Description

### Problem description

Deno Deploy fails if the server code references the vite library. I needed a custom server with vite tooling so I needed my server code to directly use the Vite framework at runtime rather than the standard Vite build system.

### Steps to reproduce

1) Min code:
```
import { createServer } from "npm:vite";
function unused() { const alias = createServer; } // Comment out this line to make things work.
Deno.serve(() => new Response(`Hello @ ${new Date().toISOString()}`));
```

2) Run `deno run --allow-net main.ts`. Note that Deno asks for `--allow-read`, `--allow-ffi`, `--allow-env`, even though those aren't used by the active code. The server runs as expected.

3) Deploy with `deployctl deploy --entrypoint main.ts --prod --project=$PROJECT_NAME --token=$DENO_DEPLOY_TOKEN`.

```
× Deployment failed.
error: The deployment failed: UNCAUGHT_EXCEPTION

Error: Cannot find module @rollup/rollup-linux-x64-gnu. npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). Please try `npm i` again after removing both package-lock.json and node_modules directory.
at requireWithFriendlyError (file:///node_modules/.deno/rollup@4.45.0/node_modules/rollup/dist/native.js:64:9)
at Object. (file:///node_modules/.deno/rollup@4.45.0/node_modules/rollup/dist/native.js:73:76)
at Object. (file:///node_modules/.deno/rollup@4.45.0/node_modules/rollup/dist/native.js:112:4)
at Module._compile (node:module:745:34)
at loadMaybeCjs (node:module:770:10)
at Object.Module._extensions..js (node:module:755:12)
at Module.load (node:module:662:32)
at Module._load (node:module:534:12)
at Module.require (node:module:681:19)
at require (node:module:816:16)
```

### Expected behavior

The server code should properly run without extra framework changes.

### Environment

deno 2.3.6 on OSX & Windows.

### Possible solution

_No response_

### Additional context

_No response_

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the failure with main.ts and the documented deployctl command. Trace the Vite createServer import and the reported Rollup optional native-module error during deployment. Done means the server deploys and runs without extra framework changes or unnecessary runtime permissions.

Written by the indexing model from the issue text.

Assessment

Tech stack
vite
Domain
backend, cloud
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.