Issues running NextJS installed with "npm create cloudflare@latest"

For Workers & Pages, what is the name of the domain?

N/A

What is the error number?

N/A

What is the error message?

ReferenceError: await is not defined

What is the issue or error you’re encountering

Issues to run NextJS

What steps have you taken to resolve the issue?

N/A

What are the steps to reproduce the issue?

Hi,

I am trying to create a new Next.js app that I will deploy to Cloudflare Pages. I am following the official documentation:

To create the new Next.js app I am using the npm command from Cloudflare in order to have a pre-configured app to run on Cloudflare Pages.
This is the command I used: npm create cloudflare@latest

However when my NodeJS app is ready and I use “npm run dev” it gives errors (ReferenceError: await is not defined).

Are you facing the same issue?

Thank you

Hi, which version of Node.js are you using? (node -v) Using the latest version might solve it since it appears to be related with await

Hi @ares ,

thank you for your reply.

I was using v21.7.3 and since it was not the latest release I also tried with v23.5.0 which is the last one released.

I am facing the same issue. I don’t know how can I fix it.

I am using your command “npm create cloudflare@latest” to create the NextJS project for Cloudflare Pages.

Hope you can help me!

Thank you :slight_smile:

I am still waiting for some help. Unfortunately I didn’t find out how to fix it yet.

Hi! I’m facing the same issues related by @HurryFlower

  • Create a new project with pnpm create cloudflare@latest my-name-app --framework=next
  • Run npm run dev
  • Throw error, await is not defined
    .

I resolve with a work around. Wrapping await into an IIFE

A workaround would be to rename next.config.ts → next.config.js and remove the types from the file:

I accidentally pressed enter without pasting the code and now I couldn’t edit my comment apparently due to my new account in this community, but here’s the code with the types removed:

import { setupDevPlatform } from '@cloudflare/next-on-pages/next-dev';

// Here we use the @cloudflare/next-on-pages next-dev module to allow us to use bindings during local development
// (when running the application with `next dev`), for more information see:
// https://github.com/cloudflare/next-on-pages/blob/main/internal-packages/next-dev/README.md
if (process.env.NODE_ENV === 'development') {
  await setupDevPlatform();
}


const nextConfig = {
  /* config options here */
};

export default nextConfig;
2 Likes