create-react-app icon indicating copy to clipboard operation
create-react-app copied to clipboard

Error migrating to Yarn 2

Open milichev opened this issue 6 years ago • 7 comments

Describe the bug

yarn install fails when trying to migrate a clean just-created CRA app to the version 2 (Berry)

Which terms did you search for in User Guide?

These are marked as closed but guys keep reporting the same issue:

  • https://github.com/yarnpkg/berry/issues/719
  • https://github.com/yarnpkg/berry/issues/886

Environment

  current version of create-react-app: 4.0.0
  running from C:\Users\milic\AppData\Local\Yarn\Data\global\node_modules\create-react-app

  System:
    OS: Windows 10 10.0.19041
    CPU: (8) x64 Intel(R) Core(TM) i7-8565U CPU @ 1.80GHz
  Binaries:
    Node: 12.19.0 - C:\Temp\yarn--1604428991134-0.7984384358311725\node.CMD
    Yarn: 1.22.10 - C:\Temp\yarn--1604428991134-0.7984384358311725\yarn.CMD
    npm: 6.14.8 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: 86.0.4240.111
    Edge: Spartan (44.19041.423.0), Chromium (86.0.622.58)
    Internet Explorer: 11.0.19041.1
  npmPackages:
    react: ^17.0.1 => 17.0.1
    react-dom: ^17.0.1 => 17.0.1
    react-scripts: 4.0.0 => 4.0.0
  npmGlobalPackages:
    create-react-app: Not Found

Steps to reproduce

yarn create react-app just-app --template typescript
cd just-app
npm install -g yarn
yarn set version berry
git add .
git commit -m "yarn version set to berry"
# at this point I tried to remove node_modules and yarn.lock but in vain
yarn install

Expected behavior

Yarn migrates to the version berry, node_modules go to .yarn/cache.

Actual behavior

The last command (yarn install) fails with the following output:

➤ YN0000: ┌ Fetch step
➤ YN0013: │ iferr@npm:0.1.5 can't be found in the cache and will be fetched from the remote registry
...
➤ YN0066: │ fsevents@patch:fsevents@npm%3A2.2.0#builtin<compat/fsevents>::version=2.2.0&hash=127e8e: Cannot apply hunk #1 (set enableInlineHunks for details)
...
➤ YN0000: └ Completed in 17s 59ms
➤ YN0000: Failed with errors in 36s 813ms

Possible workaround

I tried to create a berry structure from the beginning:

# create a higher-level directory
cd test
yarn set version berry

# this way CRA creates a nested directory and inherits the yarn version collecting the dependencies in `.yarn`
yarn create react-app just-app --template typescript
cd just-app

# but created this way, CRA does not start due to https://github.com/facebook/create-react-app/issues/9446
yarn start

#  -- Module not found: Your application tried to access react-refresh

milichev avatar Nov 03 '20 18:11 milichev

I'm getting the same behavior.

I've also tried yarn create react-app --template cra-template-pwa-typescript --use-pnp project-name with no success, but this seems to fail because of https://github.com/facebook/create-react-app/issues/5647.

tydira avatar Nov 03 '20 19:11 tydira

It looks like this PR fixes it. https://github.com/yarnpkg/berry/pull/2078

tydira avatar Nov 03 '20 21:11 tydira

This issue specifically is unrelated to CRA

merceyz avatar Nov 03 '20 22:11 merceyz

Does work with: yarn set version from sources yarn add react-refresh eslint-config-react-app

dkolba avatar Nov 27 '20 21:11 dkolba

@dkolba , yes, this is a working workaround.

milichev avatar Dec 23 '20 14:12 milichev

Any plans for the upstream fix to land in CRA or is that not needed?

timini avatar Jan 05 '21 09:01 timini

This issue (fsevents) is not related to CRA, the rest of the PnP issues are fixed in https://github.com/facebook/create-react-app/pull/9872

merceyz avatar Jan 05 '21 09:01 merceyz