Skip to content

Issues with yarn on Windows 11 #272

Closed

Description

@adiati98

Description

I forked and cloned the maintainermonth repository on my local machine.

I followed the instructions on the README to run the project locally. However, I encountered some problems when installing dependencies with yarn.

Environment

  • OS: Windows 11
  • Yarn version: v1.22.19
  • Node version: v20.17.0

How to reproduce the bug

yarn install

  1. Fork and clone the forked maintainermonth repository to your local machine.

  2. Run yarn install.

  3. You will get an error message (the path will be different depending on your directory & folder names):

    error An unexpected error occurred: "Unknown token: { line: 1379, col: 1, type: 'INVALID', value: undefined } 1379:1 in D:\\WebDev\\GitHub\\maintainermonth\\yarn.lock".

yarn start

When I could finally install the dependencies, running yarn start also gave me a problem.

  1. Run yarn start.

  2. You will get an error message (the path will be different depending on your directory & folder names):

    Error: Could not find a production build in the '.next' directory. Try building your app with 'next build' before starting the production server. https://nextjs.org/docs/messages/production-start-no-build-id
    at setupFsCheck (D:\WebDev\GitHub\maintainermonth\node_modules\next\dist\server\lib\router-utils\filesystem.js:151:19)
    at async initialize (D:\WebDev\GitHub\maintainermonth\node_modules\next\dist\server\lib\router-server.js:63:23)
    at async Server.<anonymous> (D:\WebDev\GitHub\maintainermonth\node_modules\next\dist\server\lib\start-server.js:249:36)
    error Command failed with exit code 1.

yarn build

After running yarn start, in the error message, it was mentioned: Could not find a production build in the '.next' directory. Try building your app with 'next build' before starting the production server.

So, I followed this instruction as the below:

  1. Run yarn build.

  2. You will get the error message:

    $ NODE_ENV=production next build
    'NODE_ENV' is not recognized as an internal or external command, operable program or batch file.
    error Command failed with exit code 1.

Workaround

I finally could get everything worked as expected with the below workaround:

  1. Fork and clone the forked maintainermonth repository to the local machine.

  2. Remove the yarn.lock file.

  3. Run yarn install.

    Now the dependencies can be installed without any issue, and a new yarn.lock file is generated.

  4. Run yarn dev.

    Running yarn start still doesn't work. But yarn dev runs and renders the website with no problem.

Suggestions

Sometimes, Windows users encounter problems that Mac users don't. It'd be great if other Windows users could confirm if this also happened in their machine.

If they encounter the same problem, we might want to update the instructions on the README to accommodate Windows users.

Things to consider:

  • Run yarn dev instead of yarn start
  • Recommended yarn version if preferable
  • Recommended Node version if preferable

Activity

  1. The-Best-Codes commented on Apr 21, 2025

    @The-Best-Codes
    Contributor

    Honestly, I would use pnpm (or bun, if you're feeling adventurous) instead of yarn. pnpm and bun have fantastic DX, and yarn is getting a bit slow nowadays. 🥲
    But of course, that's up to the team!

  2. TomNaughton commented on Dec 11, 2025

    @TomNaughton
    Contributor

    @chrisreddington Are you using Windows?
    I had to install cross-env and update the build script to "cross-env NODE_ENV=production next build".

    Then to test I need to run "npm run build", followed by "npx serve@latest out".

  3. andersen00319 commented on Jan 23, 2026

    @andersen00319

    first, you have to remove yarn.lock and regeneration it.
    and install node20 directly.
    second, your .env error

  4. ashleywolf commented on Mar 24, 2026

    @ashleywolf
    Contributor

    Addressed in #380 — added cross-env and updated the build script from NODE_ENV=production next build to cross-env NODE_ENV=production next build, which fixes the 'NODE_ENV' is not recognized error on Windows. README also updated with npm commands and Node.js v20 requirement. Thanks for the detailed write-up and workaround, @adiati98!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions