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

react-scripts trying to access .steampath #9825

Open rolivegab opened 4 years ago

rolivegab commented 4 years ago

Describe the bug

If some module resolution fails, react-scripts try to stat all files in user's home directory. if there are some broken link no home folder, development server crashes.

Did you try recovering your dependencies?

Yes.

Which terms did you search for in User Guide?

.steampath

Related, and explained comment: https://github.com/facebook/create-react-app/issues/9156#issuecomment-645512859

Environment

Environment Info:

  current version of create-react-app: 3.4.1
  running from /home/rolivegab/.npm/_npx/171872/lib/node_modules/create-react-app

  System:
    OS: Linux 5.8 Fedora 32 (Workstation Edition) 32 (Workstation Edition)
    CPU: (12) x64 AMD Ryzen 5 2600 Six-Core Processor
  Binaries:
    Node: 14.7.0 - ~/.nvm/versions/node/v14.7.0/bin/node
    Yarn: 1.22.5 - /usr/bin/yarn
    npm: 6.14.8 - ~/.nvm/versions/node/v14.7.0/bin/npm
  Browsers:
    Chrome: 86.0.4240.75
    Firefox: 81.0.1
  npmPackages:
    react: ^16.14.0 => 16.14.0 
    react-dom: ^16.14.0 => 16.14.0 
    react-scripts: 3.4.3 => 3.4.3 
  npmGlobalPackages:
    create-react-app: Not Found

Steps to reproduce

  1. Since it depends on machine's having a broken link on home directory, you need to create a broken file there. My .steampath file is just a broken link: image

  2. npm start

  3. force a module resolution failed, or something output:

image

Expected behavior

react-scripts should not stop development server because a broken link in home directory.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

rolivegab commented 3 years ago

Issue still persists.

KB1RD commented 3 years ago

IMHO, these scripts shouldn't be doing anything in my home directory period unless its in a specific, well-named directory specific to react scripts. What is the justification for this anyway?

panta82 commented 3 years ago

I did a bit of digging.

The bug is caused by chokidar library not policing its errors when trying to resolve symlinks. https://github.com/paulmillr/chokidar/blob/3.4.2/lib/nodefs-handler.js#L424

I'll create a bug report there.

I don't know why the script is trying to read outside of its project directory, I haven't dug that far.

EDIT: Seems they refactored all this in newer versions. watchpack should update its dependencies.

CORRECTION EDIT: Fix still not merged: https://github.com/paulmillr/chokidar/pull/1010

alexhochreiter commented 3 years ago

Today i looked closer at why my react-scripts server is randomly crashing during development (only happens after multiple hours or days) and came across the same issue as op:

Compiling...
/home/alex/work/bla/blabla/myproject/node_modules/react-scripts/scripts/start.js:19
  throw err;
  ^

[Error: ENOENT: no such file or directory, stat '/home/alex/.steampath'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'stat',
  path: '/home/alex/.steampath'
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! myproject@0.1.0 dev: `npx rimraf node_modules && npm i && react-scripts start`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the myproject@0.1.0 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/alex/.npm/_logs/2021-01-23T08_43_37_732Z-debug.log

It's easy to fix with a simple restart, but what i don't understand is: WHY THE HECK IS IT TRYING TO ACCESS MY STEAM STUFF OR STAT-ING MY PRIVATE HOME DIR AT ALL? Does Facebook really need to know what's in my steam lib or how many hours i've killed in Hatoful Boyfriend?

erfoon commented 3 years ago

Having same issue.

Compiling...
/home/erfan/Documents/GitLab/SurgAccord/surgaccord-landing/node_modules/react-scripts/scripts/start.js:19
  throw err;
  ^

[Error: ENOENT: no such file or directory, stat '/home/erfan/.steampath'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'stat',
  path: '/home/erfan/.steampath'
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Only happens when a module is not found. The main problem is that the developement crashes and I should npm start again. Which is quite annoying. Really don't know why it is behaving like that...

Alexand3r commented 3 years ago

The bug has almost an year now(this isnt the first time it has been reported #9156 ).... Maybe some additional info might help... In my case the dev server crashes completely if I use relative paths (have .env file with NODE_PATH=src) for imports like this:

import ComponentA from "myComponentsFolder/ComponentA"
import { ComponentB } from "myComponentsFolder/ComponentB"

But ComponentA.js doesn't exist inside myComponentsFolder, same thing happens if the folder doesn't exist and same thing happens if A exists and B doesn't, the dev server should throw a "ComponentA is missing", not completely crash...

As a workaround to actually find what I'm missing I'm running npm run-script build, but that's at least a minute lost everytime I'm missing a component or haven't even defined it yet....

Edit: Oh yeah, in my case I don't even see the module missing, just the error like erfoon has... Edit2: It also crashes from some npm packages downloaded but not all, I don't know which crash and which don't...

Alexand3r commented 3 years ago

@alisscco Maybe also add as a feature something like -v / --verbose to react-scripts so it doesn't clear the console?

dbersan commented 3 years ago

I'm getting this while calling npm start, is there any workaround? I keep getting the error, it never really compiles.

edit: I deleted the .steampath file and now it gives me an actual error that a package was missing. Installed the package and now it works. Simply restarting for me did not work, as others have stated.

pladaria commented 3 years ago

I'm getting this same error (when running storybook), but I have no missing package. If I delete the broken symlinks the errors stops appearing but this is very awkward

MohamedLamineAllal commented 3 years ago

The bug has almost an year now(this isnt the first time it has been reported #9156 ).... Maybe some additional info might help... In my case the dev server crashes completely if I use relative paths (have .env file with NODE_PATH=src) for imports like this:

import ComponentA from "myComponentsFolder/ComponentA"
import { ComponentB } from "myComponentsFolder/ComponentB"

But ComponentA.js doesn't exist inside myComponentsFolder, same thing happens if the folder doesn't exist and same thing happens if A exists and B doesn't, the dev server should throw a "ComponentA is missing", not completely crash...

As a workaround to actually find what I'm missing I'm running npm run-script build, but that's at least a minute lost everytime I'm missing a component or haven't even defined it yet....

Edit: Oh yeah, in my case I don't even see the module missing, just the error like erfoon has... Edit2: It also crashes from some npm packages downloaded but not all, I don't know which crash and which don't...

One can use the debugger to pause at the message point!

You can check that here: https://stackoverflow.com/a/68370804/7668448

image

MohamedLamineAllal commented 3 years ago

Today i looked closer at why my react-scripts server is randomly crashing during development (only happens after multiple hours or days) and came across the same issue as op:

Compiling...
/home/alex/work/bla/blabla/myproject/node_modules/react-scripts/scripts/start.js:19
  throw err;
  ^

[Error: ENOENT: no such file or directory, stat '/home/alex/.steampath'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'stat',
  path: '/home/alex/.steampath'
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! myproject@0.1.0 dev: `npx rimraf node_modules && npm i && react-scripts start`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the myproject@0.1.0 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/alex/.npm/_logs/2021-01-23T08_43_37_732Z-debug.log

It's easy to fix with a simple restart, but what i don't understand is: WHY THE HECK IS IT TRYING TO ACCESS MY STEAM STUFF OR STAT-ING MY PRIVATE HOME DIR AT ALL? Does Facebook really need to know what's in my steam lib or how many hours i've killed in Hatoful Boyfriend?

It's just checking the home directory! And iterating through all files! Why ?? I duno! Didn't Find why yet!

Otherwise here the same error but with a broken symlink on my name

image

hoclun-rigsep commented 3 years ago

Suggestion for others who land here, I ran

npm run start &> /tmp/output

so I could see which package was missing. &> may be a bash-specific construct—it redirects both stdout and stderr.

temisan0x commented 3 years ago

Suggestion for others who land here, I ran

npm run start &> /tmp/output

so I could see which package was missing. &> may be a bash-specific construct—it redirects both stdout and stderr.

it worked. Thanks

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

blackpatton17 commented 2 years ago

This problem still existed.

artemdumanov commented 1 year ago

+1

mnunez-radius commented 2 weeks ago

+1