0

I recently wanted to create a new nextjs project, so I used: npx create-next-app@latest my-app.

I cd'd into the my-app folder and hit yarn to install dependencies, and starting the project produced an error:

yarn dev                                                                  ─╯
   ▲ Next.js 16.0.0 (Turbopack)
   - Local:        http://localhost:3000
   - Network:      http://192.168.1.69:3000

 ✓ Starting...
Error: Turbopack build failed with 1 errors:
./app
Error: Next.js inferred your workspace root, but it may not be correct.
    We couldn't find the Next.js package (next/package.json) from the project directory: /home/person/Projectz/my-app/app
     To fix this, set turbopack.root in your Next.js config, or ensure the Next.js package is resolvable from this directory.
    Note: For security and performance reasons, files outside of the project directory will not be compiled.
    See https://nextjs.org/docs/app/api-reference/config/next-config-js/turbopack#root-directory for more information.

    at ignore-listed frames

Following different suggestions over the internet, I tried two things:

  1. Update yarn (yarn set version stable and yarned the project again ), updated to version 4.10.3

  2. update turbopack root location:

import type { NextConfig } from "next";

import * as path from 'path';

const nextConfig: NextConfig = {
  /* config options here */
    turbopack: {
        root: path.join(__dirname, '') // package.json is on the same level as next config
    }
};

export default nextConfig;

But, I'm left with the same error. I definitely like some help on how to solve these, there don't even seem much issues like this on the internet and Next16 seems relatively new without many resources. Thanks in advance.

UPDATE: I actually used npm and bun, and they seem to work fine. Is this something to do with the latest version of yarn 4.10.3 and next 16?

4
  • Do you have multiple lock files in you project? Commented Oct 23 at 12:07
  • no, I had deleted the package-lock.json, yarn-ed the project once again and the same thing persisted (reconfirmed, I only have yarn-lock.json) Commented Oct 23 at 12:29
  • I think __dirname is not available in ES module scope. Try using import.meta.url instead Commented Oct 23 at 12:38
  • @HashanHemachandra , I actually hard coded the absolute path, but, the same result Commented Oct 23 at 12:49

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.