facebook / create-react-app

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

npx create-react-app --info throws #5757

Closed rteshnizi closed 5 years ago

rteshnizi commented 5 years ago

Is this a bug report?

Yes

Environment

See issue title.

node v8.11.1 npm v6.4.1

Steps to Reproduce

  1. npx create-react-app --info
  2. See error

Expected Behavior

Show environment information. I have tried with different PCs.

Actual Behavior

npx: installed 63 in 3.815s
C:\Users\[Redacted]\AppData\Roaming\npm-cache\_npx\1252\node_modules\create-react-app\index.js

Environment Info:
(node:1252) UnhandledPromiseRejectionWarning: Error: The system cannot find the path specified.

    at Function.e.exports.sync (C:\Users\[Redacted]\AppData\Roaming\npm-cache\_npx\1252\node_modules\create-react-app\node_modules\envinfo\dist\envinfo.js:1:7778)
    at Object.copySync (C:\Users\[Redacted]\AppData\Roaming\npm-cache\_npx\1252\node_modules\create-react-app\node_modules\envinfo\dist\envinfo.js:1:104976)
    at Object.t.writeSync.e [as writeSync] (C:\Users\[Redacted]\AppData\Roaming\npm-cache\_npx\1252\node_modules\create-react-app\node_modules\envinfo\dist\envinfo.js:1:123499)
    at C:\Users\[Redacted]\AppData\Roaming\npm-cache\_npx\1252\node_modules\create-react-app\node_modules\envinfo\dist\envinfo.js:1:124274
    at Promise.all.then.e (C:\Users\[Redacted]\AppData\Roaming\npm-cache\_npx\1252\node_modules\create-react-app\node_modules\envinfo\dist\envinfo.js:1:124289)
    at <anonymous>
(node:1252) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:1252) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Timer commented 5 years ago

/cc @tabrindle

This might've been fixed as part of https://github.com/facebook/create-react-app/pull/5685, but I'm not sure.

heyimalex commented 5 years ago

I don't think it's fixed. I can reproduce this exact error with envinfo 5.11.1 and 5.12.1 and this snippet.

const envinfo = require("envinfo");

return envinfo
  .run(
    {
      System: ["OS", "CPU"],
      Binaries: ["Node", "npm", "Yarn"],
      Browsers: ["Chrome", "Edge", "Internet Explorer", "Firefox", "Safari"],
      npmPackages: ["react", "react-dom", "react-scripts"],
      npmGlobalPackages: ["create-react-app"]
    },
    {
      clipboard: true,
      duplicates: true,
      showNotFound: true
    }
  )
  .then(console.log);

That's taken from createReactApp.js. Part of the issue is that the code returns a promise and doesn't handle rejection at all, but envinfo is definitely failing. The error doesn't tell much, and the code is bundled so debugging is hard. Through trial and error I found that commenting out the clipboard option fixes it.

I tried working on envinfo, but I couldn't get it to build. It looks like src/envinfo.js works and dist/envinfo.js doesn't, so the problem probably crops up from bundling.

heyimalex commented 5 years ago

Actually I think this is just tabrindle/envinfo#57, which was closed but never resolved.

tabrindle commented 5 years ago

Hey all sorry for the delay. Based on a lot of usage feedback and compatibility problems I will be removing the bundled clipboard option from envinfo (it uses native binaries that aren't bundled with webpack), and i'll be making PRs to replace the functionality with the standalone package previously bundled in envinfo.

tabrindle commented 5 years ago

That PR just removed the clipboard option entirely - do you still want this functionality? It's not difficult to integrate - seems silly to remove instead of keeping the function the same.

iansu commented 5 years ago

Have you updated envinfo to fix the copy to clipboard functionality? We can always add it back.

tabrindle commented 5 years ago

The change to envinfo is simply a deprecation of the option, and will eventually be removed completely. I was simply going to extract the clipboard function to its local usage rather than core envinfo.

iansu commented 5 years ago

I'm not sure I follow. Are you saying you've deprecated the clipboard option in envinfo and that we'd have to add this functionality using another package?

tabrindle commented 5 years ago

Seems like you do follow - sorry if I'm doing a poor job of english today.

Clipboardy caused some headache when building envinfo because of the native binaries it depends on. envinfo is mostly used via npx, and thus is bundled and compressed using webpack. On my mac the clipboard option works, but it seems on windows the lack of the extra binary breaks it.

Here's my PR: https://github.com/facebook/create-react-app/pull/5911