deno icon indicating copy to clipboard operation
deno copied to clipboard

Support Next.JS

Open cmoog opened this issue 2 years ago • 21 comments

Tracking issue for supporting Next.JS.

cmoog avatar Nov 17 '22 02:11 cmoog

Seeing this for next info

$ deno run --allow-env --allow-read --allow-net npm:next info
error: Uncaught TypeError: _os.default.version is not a function
    at nextInfo (file:///Users/charlie/Library/Caches/deno/npm/registry.npmjs.org/next/13.0.3/dist/cli/next-info.js:68:30)
    at file:///Users/charlie/Library/Caches/deno/npm/registry.npmjs.org/next/13.0.3/dist/bin/next:140:44

$ deno --version
deno 1.28.1 (release, aarch64-apple-darwin)
v8 10.9.194.1
typescript 4.8.3

cmoog avatar Nov 17 '22 02:11 cmoog

deno run -A npm:pm2 --help same error:

TypeError: chalk.bold.green is not a function
    at Object.<anonymous> (file:///Users/some/Library/Caches/deno/npm/registry.npmjs.org/pm2/5.2.2/constants.js:24:40)

iugo avatar Nov 19 '22 04:11 iugo

same error:

TypeError: chalk.bold.green is not a function
    at Object.<anonymous> (file:///Users/some/Library/Caches/deno/npm/registry.npmjs.org/pm2/5.2.2/constants.js:24:40)

@iugo how is it same error? What command are you trying to run?

bartlomieju avatar Nov 20 '22 09:11 bartlomieju

@iugo how is it same error? What command are you trying to run?

run command deno run -A npm:pm2 --help.

same error, error info is x.y.z is not a function.

iugo avatar Nov 22 '22 00:11 iugo

$ deno run --allow-env --allow-read --allow-net npm:next info
error: Uncaught TypeError: _os.default.version is not a function
  at nextInfo (file:///Users/charlie/Library/Caches/deno/npm/registry.npmjs.org/next/13.0.3/dist/cli/next-info.js:68:30)
  at file:///Users/charlie/Library/Caches/deno/npm/registry.npmjs.org/next/13.0.3/dist/bin/next:140:44

This is caused because deno's os polyfill doesn't have a method called os.version() yet https://github.com/denoland/deno/issues/17850

khrj avatar Nov 24 '22 12:11 khrj

PRs trying to update chalk in next.js:

  • https://github.com/vercel/next.js/pull/41730
  • https://github.com/vercel/next.js/pull/11268

kt3k avatar Nov 30 '22 06:11 kt3k

Next.js doesn't seem to be using any of the chalk APIs that break without proto (those are specifically the ones with modifiers: bold, italic, e.t.c.) -- at least before it fails due to os.version() being missing, and only within next info -- I don't know if they're used elsewhere

khrj avatar Nov 30 '22 07:11 khrj

Ran into this:

╰─>$ deno run -A --unstable npm:next
error: Uncaught Error: Not implemented: v8.getHeapStatistics
  throw new Error(message);
        ^
    at notImplemented (https://deno.land/[email protected]/node/_utils.ts:23:9)
    at Object.getHeapStatistics (https://deno.land/[email protected]/node/v8.ts:19:3)
    at Object.<anonymous> (file:///Users/charlie/Library/Caches/deno/npm/registry.npmjs.org/next/13.1.6/dist/server/lib/start-server.js:17:47)
    at Object.<anonymous> (file:///Users/charlie/Library/Caches/deno/npm/registry.npmjs.org/next/13.1.6/dist/server/lib/start-server.js:71:4)
    at Module._compile (internal:ext/node/02_require.js:747:36)
    at Object.Module._extensions..js (internal:ext/node/02_require.js:780:12)
    at Module.load (internal:ext/node/02_require.js:658:34)
    at Function.Module._load (internal:ext/node/02_require.js:515:14)
    at Module.require (internal:ext/node/02_require.js:680:21)
    at require (internal:ext/node/02_require.js:820:18)
╰─>$ deno --version
deno 1.30.3 (release, aarch64-apple-darwin)
v8 10.9.194.5
typescript 4.9.4

Related to #8261

cmoog avatar Feb 15 '23 19:02 cmoog

$ deno --version
deno 1.31.0 (release, aarch64-apple-darwin)
v8 11.0.226.13
typescript 4.9.4

$ deno run -A --unstable npm:next
error: Uncaught Error: Not implemented: toDenoStdio pipe=string (ipc)
    at notImplemented (internal:deno_node/polyfills/_utils.ts:7:11)
    at toDenoStdio (internal:deno_node/polyfills/internal/child_process.ts:228:9)
    at new ChildProcess (internal:deno_node/polyfills/internal/child_process.ts:104:24)
    at spawn (internal:deno_node/polyfills/child_process.ts:102:12)
    at Object.fork (internal:deno_node/polyfills/child_process.ts:93:12)
    at setupFork (file://--/node_modules/.deno/[email protected]/node_modules/next/dist/cli/next-dev.js:401:51)
    at nextDev (file:///--/node_modules/.deno/[email protected]/node_modules/next/dist/cli/next-dev.js:458:13)

https://github.com/denoland/deno/blob/b6ac54815c1bcfa44a45b3f2c1c982829482477f/ext/node/polyfills/internal/child_process.ts#L324

cmoog avatar Feb 24 '23 16:02 cmoog

Run

deno run npm:create-next-app test --typescript

and see how next trying to read input from stdin interferes with the Deno permission prompt.

It's hard to see from the output, so you should try it yourself, but here is how it looks:

$ deno run npm:create-next-app test --typescript 
✅ Granted all read access.
✅ Granted all env access.
✅ Granted all sys access.
✅ Granted all write access.
? Would you like to use ESLint with this project? › No / Yes┌ ⚠️  Deno requests net access to "registry.npmjs.org".
├ Requested by `fetch()` API
├ Run again with --allow-net to bypass this prompt.
└ Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all net permissions) > 

Now I can input whatever I like, the terminal is completely stuck.

KnorpelSenf avatar Mar 09 '23 01:03 KnorpelSenf

@KnorpelSenf I just tried this myself, it might be that the terminal wants a 'Yes' or 'No' for the question regarding the usage of ESLint before accepting input regarding '--allow-net'

einSelbst avatar Mar 19 '23 20:03 einSelbst

`$ deno run --allow-read --allow-env --allow-write npm:create-next-app test --typescript ? Would you like to use ESLint with this project? ┬╗ No / YesError clearing stdin for permission prompt. Could not emula

√ Would you like to use ESLint with this project? ... No / Yes ? Would you like to use src/ directory with this project? » No / Yes √ Would you like to use src/ directory with this project? ... No / Yes ? Would you like to use experimental app/ directory with this project? » No / Yes √ Would you like to use experimental app/ directory with this project? ... No / Yes ? What import alias would you like configured? » @/* √ What import alias would you like configured? ... @/* Creating a new Next.js app in C:\Users\Axircle\Projects\RISET\DENO\test.

Using npm.

Initializing project with template: default

Aborting installation. Unexpected error. Please report it as a bug: NestedError: Cannot glob **: EINVAL: invalid argument, stat at file:///C:/Users/Axircle/AppData/Local/deno/npm/registry.npmjs.org/create-next-app/13.2.4/dist/index.js:43:6690 at async installTemplate (file:///C:/Users/Axircle/AppData/Local/deno/npm/registry.npmjs.org/create-next-app/13.2.4/ at async createApp (file:///C:/Users/Axircle/AppData/Local/deno/npm/registry.npmjs.org/create-next-app/13.2.4/dist/i at async run (file:///C:/Users/Axircle/AppData/Local/deno/npm/registry.npmjs.org/create-next-app/13.2.4/dist/index.j Caused By: Error: EINVAL: invalid argument, stat at __node_internal_captureLargerStackTrace (ext:deno_node/internal/errors.ts:89:11) at __node_internal_uvException (ext:deno_node/internal/errors.ts:182:12) at denoErrorToNodeError (ext:deno_node/internal/errors.ts:1826:16) at ext:deno_node/_fs/_fs_stat.ts:83:97 `

when install, has error

Ariska138 avatar Mar 21 '23 08:03 Ariska138

hello, any update for this does it work properly?

lash0000 avatar Jun 17 '23 02:06 lash0000

@lash0000 , no it doesn't work yet.

  • deno run -A npm:create-next-app nextjs-app --typescript
  • deno task dev or deno task lint

Results:

➜ deno task lint
Warning Currently only basic package.json `scripts` are supported. Programs like `rimraf` or `cross-env` will not work correctly. This will be fixed in an upcoming release.
Task lint next lint
error: Uncaught (in promise) ReferenceError: module is not defined
module.exports = nextConfig
^
    at file:///Users/admin/repos/nextjs-app/next.config.js:4:1

birkskyum avatar Sep 21 '23 14:09 birkskyum

omg, my reply didn't age well I think the NextJS now is focusing to make some support for Bun hmm what do you think? i'm about to use Deno for some reason but because of Bun's V1 release he make me mad to pick a choice haha what can I do for now

since the NextJS still didn't make any support for Deno

lash0000 avatar Sep 21 '23 15:09 lash0000

@lash0000 , bun is still really really buggy, not in a state most people would consider stable enough for a v1, and the same goes for the deno npm-compat, so my recommendation would be to save your energy dealing with this decision and all the bugs you'll hit, and just use node / npm/yarn/pnpm for another half year and re-evaluate the situation.

birkskyum avatar Sep 21 '23 15:09 birkskyum

ok, that was a simple thing I get it thanks

lash0000 avatar Sep 21 '23 15:09 lash0000

@lash0000 , bun is still really really buggy, not in a state most people would consider stable enough for a v1, and the same goes for the deno npm-compat, so my recommendation would be to save your energy dealing with this decision and all the bugs you'll hit, and just use node / npm/yarn/pnpm for another half year and re-evaluate the situation.

A use case that would be useful for me is to deploy an app with nextjs for the desktop using the functionality of generating a static executable from deno (deno compile), I don't want to have to add all the nodejs files as a dependency in my app.

If there is any similar functionality in nodejs.

guilhermewerner avatar Dec 29 '23 11:12 guilhermewerner

@littledivy since this issue was assigned to you, does this mean that you're working on this?

KnorpelSenf avatar Apr 30 '24 09:04 KnorpelSenf

Yes, this issue is not updated regularly but progress is being made.

Most recent update is that next dev should work with Deno: https://github.com/denoland/deno/issues/23402#issuecomment-2067558806

Other closed issues are here: https://github.com/denoland/deno/issues?q=is%3Aissue+nextjs+is%3Aclosed

littledivy avatar Apr 30 '24 10:04 littledivy

Quick update: All of Next.js 14 is expected to work with DENO_FUTURE=1 as of 1.43.5

We're testing out Next.js 15 (via canary) before it releases:

  • https://github.com/denoland/deno/issues/23942
  • https://github.com/denoland/deno/issues/23943

These fixes will be available next minor release (1.44)

We're also working on sst/open-next to enable Next.js deployments on Deno's AWS Lambda layer via sst

  • https://github.com/sst/open-next/pull/419

littledivy avatar May 23 '24 05:05 littledivy

Blocked on https://github.com/denoland/deno/issues/19993

bartlomieju avatar Jun 11 '24 14:06 bartlomieju