Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Next.JS #16679

Closed
cmoog opened this issue Nov 17, 2022 · 22 comments · Fixed by #24216
Closed

Support Next.JS #16679

cmoog opened this issue Nov 17, 2022 · 22 comments · Fixed by #24216
Assignees
Labels
needs investigation requires further investigation before determining if it is an issue or not node compat

Comments

@cmoog
Copy link
Contributor

cmoog commented Nov 17, 2022

Tracking issue for supporting Next.JS.

@cmoog
Copy link
Contributor Author

cmoog commented Nov 17, 2022

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
Copy link
Contributor

iugo commented Nov 19, 2022

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 bartlomieju added the needs investigation requires further investigation before determining if it is an issue or not label Nov 20, 2022
@bartlomieju
Copy link
Member

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
Copy link
Contributor

iugo commented Nov 22, 2022

@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
Copy link
Contributor

khrj commented Nov 24, 2022

$ 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
#17850

@kt3k
Copy link
Member

kt3k commented Nov 30, 2022

PRs trying to update chalk in next.js:

@khrj
Copy link
Contributor

khrj commented Nov 30, 2022

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
Copy link
Contributor Author

cmoog commented Feb 15, 2023

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
Copy link
Contributor Author

cmoog commented Feb 24, 2023

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

@KnorpelSenf
Copy link
Contributor

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
Copy link

@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
Copy link

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

lash0000 commented Jun 17, 2023

hello, any update for this does it work properly?

@birkskyum
Copy link
Contributor

@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

@lash0000
Copy link

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
Copy link
Contributor

birkskyum commented Sep 21, 2023

@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
Copy link

ok, that was a simple thing I get it thanks

@GuilhermeWerner
Copy link

@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
Copy link
Contributor

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

@littledivy
Copy link
Member

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

Most recent update is that next dev should work with Deno: #23402 (comment)

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

@littledivy
Copy link
Member

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
Copy link
Member

Blocked on #19993

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs investigation requires further investigation before determining if it is an issue or not node compat
Projects
None yet
Development

Successfully merging a pull request may close this issue.