denoland / denoland/deploy_feedback

[Bug]: Can not build NextJs because the error - Type error: Cannot find name 'Deno'

Open
#834 2 comments 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

Follow the [demo guide](https://docs.deno.com/examples/next_tutorial/) and [deploy guide](https://deno.com/blog/nextjs-on-deno-deploy), I want to try to do. Then I want to create an api to get Deno version which use `Deno.version.deno`. It works with dev mode. Unfortunately, get error `Type error: Cannot find name 'Deno'`

### Steps to reproduce

Step 1: Follow the guide https://docs.deno.com/examples/next_tutorial/
Step 2: So I create an Nextjs api at the file `app/api/hello/route.rs`:

```ts
export async function GET (req: Request) {
return new Response(`Hello, from Deno v${Deno.version.deno}!`);
};
```
Step3: Try to build and become a failure with `deno task build`. It tells that:

```terminal
$ deno task build

Creating an optimized production build ...
✓ Compiled successfully
Linting and checking validity of types ..Failed to compile.

./app/api/hello/route.ts:2:43
Type error: Cannot find name 'Deno'.

1 | export async function GET (req: Request) {
> 2 | return new Response(`Hello, from Deno v${Deno.version.deno}!`);
| ^
3 | };
Next.js build worker exited with code: 1 and signal: null
```

### Expected behavior

I expect there is no error like that.

### Environment

- Deno 2.2.3 (stable, release, aarch64-apple-darwin)
v8 13.4.114.11-rusty
typescript 5.7.3
- Mac Sequoia

### Possible solution

_No response_

### Additional context

_No response_

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the failure in app/api/hello/route.ts by following the linked Next.js guides and running deno task build. Inspect how the build handles the Deno reference in that route; done means the production build completes without the Cannot find name 'Deno' error.

Written by the indexing model from the issue text.

Assessment

Tech stack
next.js, typescript
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.