Skip to content

Issues with yarn on Windows 11 #272

Open
@adiati98

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

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