denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
97.43k stars 5.37k forks source link

Support Next.JS #16679

Closed cmoog closed 4 months ago

cmoog commented 1 year ago

Tracking issue for supporting Next.JS.

cmoog commented 1 year ago

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
iugo commented 1 year ago

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)
bartlomieju commented 1 year ago

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?

iugo commented 1 year ago

@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.

khrj commented 1 year ago
$ 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

kt3k commented 1 year ago

PRs trying to update chalk in next.js:

khrj commented 1 year ago

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

cmoog commented 1 year ago

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/std@0.177.0/node/_utils.ts:23:9)
    at Object.getHeapStatistics (https://deno.land/std@0.177.0/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 commented 1 year ago
$ 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/next@13.2.1/node_modules/next/dist/cli/next-dev.js:401:51)
    at nextDev (file:///--/node_modules/.deno/next@13.2.1/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

KnorpelSenf commented 1 year ago

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.

einSelbst commented 1 year ago

@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'

Ariska138 commented 1 year ago

`$ 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

lash0000 commented 1 year ago

hello, any update for this does it work properly?

birkskyum commented 1 year ago

@lash0000 , no it doesn't work yet.

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
lash0000 commented 1 year ago

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

birkskyum commented 1 year ago

@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.

lash0000 commented 1 year ago

ok, that was a simple thing I get it thanks

guilhermewerner commented 10 months ago

@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.

KnorpelSenf commented 6 months ago

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

littledivy commented 6 months ago

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 commented 5 months ago

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:

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

bartlomieju commented 5 months ago

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