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

aftre install package next utils.js error #9

Open
theeranan opened this issue May 10, 2023 · 4 comments
Open

aftre install package next utils.js error #9

theeranan opened this issue May 10, 2023 · 4 comments

Comments

@theeranan
Copy link

yarn run v1.22.19
$ next
D:\Dev\nextjs_ws_apollo\node_modules\next\dist\build\utils.js:1
"httpServer: server,
^^^^^^^^^^^^^^^^^^^^

SyntaxError: Invalid or unexpected token
at internalCompileFunction (node:internal/vm:73:18)
at wrapSafe (node:internal/modules/cjs/loader:1176:20)
at Module._compile (node:internal/modules/cjs/loader:1218:27)
at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
at Module.load (node:internal/modules/cjs/loader:1117:32)
at Module._load (node:internal/modules/cjs/loader:958:12)
at Module.require (node:internal/modules/cjs/loader:1141:19)
at require (node:internal/modules/cjs/helpers:110:18)
at Object. (D:\Dev\nextjs_ws_apollo\node_modules\next\dist\build\worker.js:13:14)
at Module._compile (node:internal/modules/cjs/loader:1254:14)

Node.js v18.16.0
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

@enex
Copy link

enex commented May 26, 2023

The problem ist the patch expects new NextServer({

const index = lines.findIndex((line) => line.endsWith("new NextServer({"));
but can't find it and thus it inserts it at the top, because find index returns `-1`. A possible solution would be to find out where new NextServer({ is located now and target this file instead, also helpful would be an error if the line was not found.

Just my thoughts (next.js version 13.4.2)

@tarik02
Copy link

tarik02 commented Jul 17, 2023

The problem ist the patch expects new NextServer({

const index = lines.findIndex((line) => line.endsWith("new NextServer({"));

but can't find it and thus it inserts it at the top, because find index returns -1. A possible solution would be to find out where new NextServer({ is located now and target this file instead, also helpful would be an error if the line was not found.

Just my thoughts (next.js version 13.4.2)

Actually, for for next 13.4.10 it works without this patch (but requires patch from #6). It seems they just added httpServer there. Currently I just use this yarn patch:

.yarn/patches/next-plugin-websocket-npm-0.1.2-0ca3921bb0.patch

diff --git a/dist/index.js b/dist/index.js
index 5f6fb7271d28b806eb4d47ec04f19a9a628df7f8..4501b2ed3005c552cecdae6d0737f6148b2ea953 100644
--- a/dist/index.js
+++ b/dist/index.js
@@ -78,7 +78,10 @@ function hookNextNodeServer() {
         if (!isPageFound)
             return false;
         // Ensure that the page gets built, if it exists
-        await this.ensureApiPage(page);
+        await this.ensureEdgeFunction({
+            page,
+            appPaths: null,
+        });
         // Get the path of the built page. Will throw an error if the page doesn't
         // exist. This is fine to ignore, as it just falls into one of the many
         // other 404's that Next.js doesn't really do anything with
diff --git a/dist/patch.js b/dist/patch.js
index 5c92ad9de13d1b15a61b1a08d36ddae98c22ad53..955e1f1d65ab8dd015855f41e53c6d7be13cb697 100644
--- a/dist/patch.js
+++ b/dist/patch.js
@@ -34,7 +34,7 @@ const mod = template_1.default.expression.ast `require("next-plugin-websocket")`
 async function main() {
     await patchNextNodeServer();
     await patchWebpackConfig();
-    await patchStandaloneServer();
+    // await patchStandaloneServer();
 }
 main();
 async function patchNextNodeServer() {

@tarik02
Copy link

tarik02 commented Jul 18, 2023

Actually there is problem with standalone server (this vercel/next.js#44209)

@anurag-roy
Copy link

Was anyone able to make this (or any other workaround) work for Next.js 14?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants