facebook / create-react-app

Set up a modern web app by running one command.
https://create-react-app.dev
MIT License
102.83k stars 26.88k forks source link

running create-react-app with npx unexpectedly installs create-react-app via yarn #10617

Open AskAlice opened 3 years ago

AskAlice commented 3 years ago

Describe the bug

by using NPX it implies that the user wants to use NPM, however create-react-app forces the zucc onto the users with yarn anyway.

Did you try recovering your dependencies?

Yes. This does fix the issue. But that's not the problem. The problem is that by using NPX it implies that I want to use NPM. If i were using yarn I would be using yarn create react-app

Which terms did you search for in User Guide?

I searched for issues that are like this but I couldn't find any.

Environment

  current version of create-react-app: 4.0.3
  running from /home/alice/.npm/_npx/9475/lib/node_modules/create-react-app

  System:
    OS: Linux 4.4 Ubuntu 18.04.4 LTS (Bionic Beaver)
    CPU: (24) x64 AMD Ryzen 9 3900X 12-Core Processor
  Binaries:
    Node: 12.16.1 - ~/.nvm/versions/node/v12.16.1/bin/node
    Yarn: 1.22.4 - /usr/bin/yarn
    npm: 6.14.4 - ~/.nvm/versions/node/v12.16.1/bin/npm
  Browsers:
    Chrome: Not Found
    Firefox: Not Found
  npmPackages:
    react: ^17.0.1 => 17.0.1
    react-dom: ^17.0.1 => 17.0.1
    react-scripts: 4.0.2 => 4.0.2
  npmGlobalPackages:
    create-react-app: Not Found

Steps to reproduce

npx create-react-app thisbug
cd thisbug
npm i express --save
find node_modules/.bin -type l ! -exec test -e {} \; -print # detects broken symlinks. output: node_modules/.bin/node-which

Expected behavior

I expect it to use NPM to install. Yes I know there is a --use-npm flag, but that is beyond the point.

the find command returns no output, implying there are no broken symlinks

Actual behavior

node_modules/.bin/node-which is a broken symlink.

Yes I understand that this is a compatibility issue with npm and yarn.. specifically on ubuntu (not a problem on windows), however, rather than taking this up with NPM I think it's better to blame create-react-app as yarnpkg was not expected to run in this situation as npx is provided by npm.

note this screenshot was taken after running npx create-react-app thisbug && cd thisbug then npm i express --save image

(Write what happened. Please add screenshots!)

Reproducible demo

npx create-react-app my-app

# installing via yarnpkg
RegistryHJ commented 3 years ago

Check your yarn global add list

% yarn global list
info "create-react-app@4.0.3" has binaries:
   - create-react-app

if yarn has CRA binaries you can remove it

% yarn global remove create-react-app

and you excute npx

% npx create-react-app my-app

How is it executed?

AskAlice commented 3 years ago

I think you're misunderstanding. This isn't a configuration issue. I have never really used yarn... like ever.

But sure, here's the output.

❯  yarn global list
yarn global v1.22.4
Done in 0.06s.
❯ yarn global remove create-react-app
yarn global v1.22.4
[1/2] Removing module create-react-app...
error This module isn't specified in a package.json file.
info Visit https://yarnpkg.com/en/docs/cli/global for documentation about this command.