Create react app невозможно загрузить файл
Пытаюсь запустить проект с помощью Create React App через команду "npm start" и получаю вот такую ошибку:
There might be a problem with the project dependency tree.
It is likely not a bug in Create React App, but something you need to fix locally.
The react-scripts package provided by Create React App requires a dependency:
Don't try to install it manually: your package manager does it automatically.
However, a different version of webpack was detected higher up in the tree:
C:\Users\Алексей\node_modules\webpack (version: 4.16.3)
Manually installing incompatible versions is known to cause hard-to-debug issues.
If you would prefer to ignore this check, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
That will permanently disable this message but you might encounter other issues.
To fix the dependency tree, try following the steps below in the exact order:
1. Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.
2. Delete node_modules in your project folder.
3. Remove "webpack" from dependencies and/or devDependencies in the package.json file in your project folder.
4. Run npm install or yarn, depending on the package manager you use.
In most cases, this should be enough to fix the problem.
If this has not helped, there are a few other things you can try:
6. Check if C:\Users\Алексей\node_modules\webpack is outside your project directory.
For example, you might have accidentally installed something in your home folder.
7. Try running npm ls webpack in your project folder.
This will tell you which other package (apart from the expected react-scripts) installed webpack.
If nothing else helps, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
That would permanently disable this preflight check in case you want to proceed anyway.
P.S. We know this message is long but please read the steps above :-) We hope you find them helpful!
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! password-lock@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the password-lock@0.1.0 start 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! C:\Users\Алексей\AppData\Roaming\npm-cache\_logs\2019-05-16T21_36_42_995Z-debug.log
I am trying to use npx create-react app but i have errors that is shown below:
and the log file of the error is here.
How I can get rid of this trouble??
24 Answers 24
To fix the issue, run these commands in sequence
it's working thanks. But why it not working direct command(npx create-react-app frontend) in windows?
I had the same issue "Install for create-react-app@latest failed with code 7" Use this. It worked for me.
Clean npm cache:
First, clear cache by typing this in your terminal:
Then upgrade your version of npm by either following these steps or type:
Now go to "NodeJS" in Programs and Features in your Windows settings and Repair your installation.
Restart terminal and type:
This should hopefully fix your issue.
The above commands din't work on my windows. I have Node >= 6 and npm >= 5.2 on my machine even then it is not able to open localhost:3000 then I used this commands
This worked for me!!
first you need to create the package.json file by npm init
then npx create-react-app myapp
Sometime it happens because of slow internet speed. Try with this one.
Default timeout=30000(30sec). increase timeout, if you necessary.
The problem arises due to so many reasons.
- This happens is if one of the node modules requires to install your react app is missing.
- The other reason is if your have and unstable network connection.
- Sometimes, but on rare cases, your antivirus may assume the cmd files in your cache to be malware.
if your antivirus is your issue, disable it for the period you run the commands.
Whatever the reason for npx create-react-app is not working on your machine, run the following commands in sequence:
let me know if this worked for you
This worked for me. The first time I tried the npx command everything seemed to be going well until it printed out "A template was not provided". I ran the "npm cache clean --force" and then ran the npx command and this time it installed the template dependencies as expected. Thank you!
In your antivirus whitelist the node software
hey guys in my point of view, check your system any antivirus is running and blocking the node.exe more specifically (ByteFence Anti-malware)
In my case its blocking the node system call
I quit this from hidden icons in the system tray it works fine for me
when you do => npm start
- you may have seen some antivirus asks permission to add it to whitelist or add it to block list that antivirus you should stop or add whitelist to it
Thank you so much. It really helped a lot. I kept on trying all the solution but didn't work. Issue was due to antivirus only.
Same issue, and here is my solution.
there is bug because your user pc name contains space , you could resolve this with this code :
Run Windows PowerShell as administrator and type this:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
You don't need to install the create-react-app package globally. 'npx' is already installing with the latest version.
In your antivirus whitelist the node software
hey guys in my point of view, check your system any antivirus is running and blocking the node.exe more specifically (ByteFence Anti-malware)
In my case its blocking the node system call
I quit this from hidden icons in the system tray it works fine for me
- sometimes you may seen some antivirus asks permission to add it to whitelist or add it to block list that antivirus you should stop or add whitelist to it
I tried everything and nothing worked.
I then restarted my laptop, and when I tried npm init followed with npm install create-react-app I got an Avast potential harmful file alert, but it was ok and I confirmed it. That create-react-app attempt failed, but when I tried it again it worked.
It's possible that a firewall or such is blocking node from carrying out a function, hence why it's throwing a callback() never called error.
Help! I have no idea what is going on here, create react app is not working I have also tried reinstalling and yet to no avail, please help!
Npm version: 5.4.2 Node version: 8.70
Tried the npm install --save --save-exact --loglevel error react react-dom react-scripts
Please post your node and npm versions ( node -v and npm -v respectively). Checking github issues might be helpful as well.
Hmmm. I cannot reproduce this. Can you try copying and running the npm install --save --save-exact . command? Also, I saw you posted this question on github. I don't know what the stackoverflow best practice is, but if you get an answer there, please repost it as a solution here as well.
reach009 commented Dec 3, 2020 •
I am able to solve the problem by first trying to uninstall the npm globally, update the npm, clear the cache then using npx command to create React app.
The command is as below:
npm uninstall -g create-react-app && npm i -g npm@latest && sudo npm cache clean -f && npx create-react-app my-app
This is taken from one of the Stack Overflow posts.
devnuru commented Nov 30, 2020
I solved this using the following command.
npm uninstall -g create-react-app
then
npm install -g create-react-app
It's not working for me. Please help me! 😢
Again I saw this error----
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path D:\udemy/package.json
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, open 'D:\udemy\package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\User\AppData\Local\npm-cache_logs\2020-11-30T20_18_36_036Z-debug.log
imrishav commented Nov 26, 2020
I solved this using the following command.
npm uninstall -g create-react-app
npm install -g create-react-app
On Thu, Nov 26, 2020, 12:02 Rishav Sinha ***@***.***> wrote: I solved this using the following command. npm uninstall -g create-react-app then npm install -g create-react-app — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub , or unsubscribe .
MahrezDev commented Dec 3, 2020
jmischka commented Dec 19, 2020
I've also run into the same problem as others above and have been going around in circles for 2 hours. My steps:
'npm uninstall -g create-react-app' (even though I never installed create-react-app globally),
'npm cache clean --force' (I also tried 'sudo npm cache clean -f')
then 'npx create-react-app my-app.'
Yet, I'm still running an error that I have it globally installed:
You are running create-react-app 4.0.0, which is behind the latest release (4.0.1).
We no longer support global installation of Create React App.
I'm at a loss and stuck in what feels like a maze. My next step is to manually start deleting and files as baalansellers suggests, but I don't think that should be necessary.
BenJenkinson commented Feb 25, 2021
I'm sorry @mrmckeb, I assumed that npm 's behaviour was intentional. I didn't think to look there for a cause! Thank you for digging!
That would fit my own situation (because I was using npm@7.5.1 ), but looking at @peterbe's original log output, he was on npm@7.5.6 when he had this problem.
BenJenkinson commented Feb 24, 2021
I just encountered this problem as well.
As a possible workaround, this worked for me:
original post
also chiming in here. i think there's a dependency issue somewhere, as i've confirmed this is happening on node v12.18.0 and v15.3.0:
mxtetrachord commented Dec 2, 2020 •
nope, this was my registry being poorly set up—i was trying to hit my company's scoped registry, which hadn't yet ingested no-case@3.0.4 . i'm all set.
So, where did the change come from?
Fnjn commented Feb 24, 2021 •
@BenJenkinson I can confirm that running out-of-date create-react-app version triggers this error.
I think it's very unreasonable to require latest release. Many companies requires developers to use internal npm repo, which is often a few days or weeks behind. I don't see the point forcing everyone to use up-to-date version, unless there's a severe security issue.
SamuliPeltonen commented Nov 28, 2020
I solved this using the following command.
npm uninstall -g create-react-app
then
npm install -g create-react-app
Thanks for this! Worked for me too.
tomcavanaugh commented Dec 2, 2020
I had to run both of the following commands to resolve this issue.
- npm uninstall -g create-react-app
- yarn global remove create-react-app
Possibly the wording on the following error message could be updated to indicate that both of these commands may be required.
Change:
Please remove any global installs with one of the following commands:
To:
Please remove any global installs with one or both of the following commands:
baalansellers commented Dec 8, 2020
This worked for me too, however, I went into ~/.npm/_npx//node_modules and deleted the create-react-app directory specifically. Then, just to be very sure, I also manually edited ~/.npm/_npx//package.json and set the version for create-react-app to 4.0.1, even though it was marked with a carrot already.
Then I ran npx create-react-app . again, it prompted to install it, hit "y", and I was back in business.
reach009 commented Jan 26, 2021
@1-pro: Can you share more details on the error messages you got?
it isn't working for me, please help nothing is working for me
lonaveer commented Jan 29, 2021
$ npx create-react-app test
Creating a new React app in C:\React_TEE\test.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template.
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! Found: type-fest@0.11.0
npm ERR! node_modules/type-fest
npm ERR! type-fest@"^0.11.0" from ansi-escapes@4.3.1
npm ERR! node_modules/ansi-escapes
npm ERR! ansi-escapes@"^4.3.1" from jest-watch-typeahead@0.6.1
npm ERR! node_modules/jest-watch-typeahead
npm ERR! jest-watch-typeahead@"0.6.1" from react-scripts@4.0.1
npm ERR! node_modules/react-scripts
npm ERR! react-scripts@"" from the root project
npm ERR! ansi-escapes@"^4.2.1" from @jest/core@26.6.3
npm ERR! node_modules/@jest/core
npm ERR! @jest/core@"^26.6.0" from jest@26.6.0
npm ERR! node_modules/jest
npm ERR! jest@"26.6.0" from react-scripts@4.0.1
npm ERR! node_modules/react-scripts
npm ERR! 1 more (jest-watch-typeahead)
npm ERR! 1 more (jest-cli)
npm ERR! 2 more (jest-watcher, terminal-link)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peerOptional type-fest@"^0.13.1" from @pmmmwh/react-refresh-webpack-plu
gin@0.4.2
npm ERR! node_modules/@pmmmwh/react-refresh-webpack-plugin
npm ERR! @pmmmwh/react-refresh-webpack-plugin@"0.4.2" from react-scripts@4.0.1
npm ERR! node_modules/react-scripts
npm ERR! react-scripts@"" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See C:\Users\Miku\AppData\Local\npm-cache\eresolve-report.txt for a ful
l report.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Miku\AppData\Local\npm-cache_logs\2021-01-29T19_19_32_095
Z-debug.log
Aborting installation.
npm install --save --save-exact --loglevel error react react-dom react-scripts
cra-template has failed.
Deleting generated file. package.json
Deleting test/ from C:\React_TEE
Done.
npm ERR! code 1
npm ERR! path C:\React_TEE
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c create-react-app test
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Miku\AppData\Local\npm-cache_logs\2021-01-29T19_19_32_148
Z-debug.log
npm uninstall create-react-app
npm uninstall -g create-react-app
npm i -g npm@latest
npm cache clean -f
npx create-react-app my-app
.
.
.
Happy hacking!
peterbe commented Feb 24, 2021
You're right! I didn't even notice the You are running create-react-app 4.0.1, which is behind the latest release (4.0.3). line till now. Nuts.
I think I know why my brain didn't stop that. Because the prompt asked
So you're definitely thinking that this need to be installed and that it would use the latest and greatest.
I guess the mystery is; where and why is npx caching these things? npx --help doesn't state anything obvious. Perhaps I need to dig much deeper into how npm works and env vars or something. Sigh.
BenJenkinson commented Feb 24, 2021 •
I think there are two scenarios that can happen, and I think the error message is shown for both but the contents of the error message only apply to one of the scenarios.
- The version of create-react-app run being out-of-date because it was installed globally
- ✅ show error message, instructions to uninstall globally apply
- ▶ Resolved with instructions in error message
- ❌ shows same error message, instructions don't help at all, lots of stuck people with issues
- ▶ Resolved by npx create-react-app@latest my-app
I also don't think it helps that the error message is so definitive about the global install being the only reason you're seeing the error (it's not checking for a global install after all, only checking if there's a newer version)
peterbe commented Feb 24, 2021
So a lot of people fall into this pitfall. Bummer. If we change the documentation to recommend using @latest , so many of those filed issues would go away. In a sense. Is that an interesting option?
jmischka commented Dec 24, 2020
For those who ran into similar issues I had, baalansellers (3 above) had the answer. Thanks!
". ~/.npm/_npx//node_modules and deleted the create-react-app directory specifically. Then, just to be very sure, I also manually edited ~/.npm/_npx//package.json and set the version for create-react-app to 4.0.1, even though it was marked with a carrot already.Then I ran npx create-react-app . again, it prompted to install it, hit "y", and I was back in business. "
PaulB-H commented Feb 25, 2021 •
Latest version of npm fixed it for me.
npm install -g npm@latest
then:
npx create-react-app myappasks: `Need to install the following packages: create-react-app Ok to proceed? (y)`Running from terminal in VS code did not ask this, and seems to worked as usual.
Reproducible demo
The text was updated successfully, but these errors were encountered:
salimdason commented Nov 30, 2020
I solved this using the following command.
npm uninstall -g create-react-app
then
npm install -g create-react-appIt's not working for me. Please help me! 😢
Again I saw this error----npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path D:\udemy/package.json
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, open 'D:\udemy\package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoentnpm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\User\AppData\Local\npm-cache_logs\2020-11-30T20_18_36_036Z-debug.log"npx create-react-app my-app" instead of "npm install -g create-react-app"
jaronsummers commented Dec 6, 2020 •
I have never had create-react-app installed and still receive this error. In fact, I have no npm packages installed at all, but it still warns that I am running 4.0.0, and that global installation is no longer supported, and then exits.
node 14.15.0, have tried clearing the npm cache.
BenJenkinson commented Feb 24, 2021 •
This same kind of issue has been reported several times now:
-
"start fails right after create-react-app" "Not working after update" "npx create-react-app is not working" "Issues with running npx create-react-app on node 15.2.1" "npx create-react-app my-app is isn't installing the packages and i try uninstalling npm using -g but still" "error running npx create-react-app@next"
These were all ultimately resolved with either:
I suspect this is because the warning against "global" installs is really just checking for "is the version being run the latest version" which would be OK immediately after installing it globally, but then wouldn't be OK two weeks & two new versions later.
There are also a lot of solutions that suggest completely uninstalling and reinstalling node & npm , which I think is mostly a really dramatic way to ensure you have cleared npm 's (and presumably npx 's) cache of installed packages.
salimdason commented Nov 28, 2020
- First, you'll need to uninstall "create-react-app" using the "npm uninstall -g create-react-app" command.
- Run "npx create-react-app my-app" each time you want to create a new React app.
Hope you find this helpful
19 Answers 19
In my case, "create-react-app" was not installed. to install run this command
Once installation successful, try running
If this works for you. Great else comment what worked for you,
This actually work, Since, I wasn't getting any error on the cmd. But the problem I faced was incomplete create-react-app setup. So, running npx create-react-app hello-world saved me from trouble.
Please try this:
I had the same problem and had to do the following:
After this I was able to create the app with:
I had the same problem, and I solved it by:
1. update the npm version (npm install npm@latest -g)
2. clear the cache (npm cache clean --force)
3. create the react project (npx create-react-app todo)
(create-react-app was already installed)Make sure you are not running any antivirus, stop/pause all antivirus or protection software.
You can also try
as the error suggests, you should use a newer version of node. You are using 8.9.4, you should probably use 8.12.0 LTS.
It was the anti-virus software. I am using bit-defender anti-virus, disabled it completely for 30 mins and tried running the command it worked.
I had similar issue while tried creating new react app with create-react-app , but related to some random JSON reading issues while installations like.. >= 5.0 || 4.0 ..
But the fix below solves multiple and similar issues.
First of all, make sure you have required or latest version of node installed.
Before using create-react-app make sure you clean npm cache using npm cache clean --force
Now, is should be fine to create new react app with npx create-react-app tl-app or npx create-react-app . if you want to create current directory as project root.
You are running create-react-app 4.0.0, which is behind the latest release (4.0.1).
We no longer support global installation of Create React App.
Please remove any global installs with one of the following commands:
- npm uninstall -g create-react-app
- yarn global remove create-react-app
npm ERR! code 1
npm ERR! path C:\Users\User\Desktop
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c create-react-app my-appnpm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\User\AppData\Local\npm-cache_logs\2020-11-23T18_27_48_723Z-debug.logThe text was updated successfully, but these errors were encountered:
Environment
OSX Big Sur
npm 7.5.6
node v15.2.1peterbe commented Feb 24, 2021
Excellent! A solution could be to improve the error messaging to mention this thing about it being potentially cached. Because I don't have create-react-app installed globally so that part of the error wasn't helping me.
This idea actually feels more correct and less hacky that forcing that @latest thing should you shouldn't ultimately need to do.A middle-ground option might be to mention some of these things, as a loud warning/note, in the documentation.
I still don't know what this create-react-app 4.0.1 is on my machine.(Also, I hate that I now have 3 ways of running NPM packages: npm install -g , yarn global and npx )
1-pro commented Jan 25, 2021
it isn't working for me, please help nothing is working for me
joselvelez commented Feb 24, 2021
I just encountered this problem as well.
As a possible workaround, this worked for me:
Thanks! This worked for me.
Actual behavior
See error above.
peterbe commented Feb 24, 2021
So all we have to do is sit tight and wait for a new release? That seems reasonable. We can simply keep this issue open till 4.0.4 comes out and then we go back and check that you no longer need to add the @latest to make it work. And if so, close this.
Expected behavior
That it should create a directory called my-app .
peterbe commented Feb 24, 2021 •
I think it's very unreasonable to require latest release.
No one is saying that that is what you have to do. npx create-react-app my-app should work. That's what we're trying to figure out. What's next is to figure out if it's a matter of documentation, bug in the CLI, or improvements to the error messaging.
reach009 commented Dec 2, 2020
**npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /Users/reach/Documents/Personal Projects/Service_Project/iCareerZ/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/Users/reach/Documents/Personal Projects/Service_Project/iCareerZ/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoentnpm ERR! A complete log of this run can be found in:
npm ERR! /Users/reach/.npmrc/_logs/2020-12-02T01_50_49_350Z-debug.log**I also got the same problem. I try "npx create-react-app my-app" and it seems like not working. Please help
Did you try recovering your dependencies?
Which terms did you search for in User Guide?
trydalch commented Dec 4, 2020
Worked for me as well. Don't forget to update npm. I initially tried all the steps besides that and it kept thinking I still had create-react-app installed globally even though I didn't.
kusaljay commented Dec 4, 2020
This worked for me. Thank you very much @reach009
Steps to reproduce
DashBarkHuss commented Dec 23, 2020
For me I got the same error even though create-react-app was installed in a parent directory, not globally. So I ran npm uninstall create-react-app without the -g flag and it worked.
Sverxsro4nik commented Feb 23, 2021
Faced a similar problem. The package was not installed globally, but there is no way to deploy the project
Ivy2012 commented Dec 21, 2020
This did the trick for me. Thanks!
ImBobot commented Dec 5, 2020 •
I don't know about this one, but after installing npm i -g yarn and then that's the time I started building project using
npx create-react-app my_app It works for me. Oh update npm.BenJenkinson commented Feb 24, 2021 •
So all we have to do is sit tight and wait for a new release? That seems reasonable. We can simply keep this issue open till 4.0.4 comes out and then we go back and check that you no longer need to add the @latest to make it work. And if so, close this.
I'm not sure it's related to 4.0.3 specifically. After all, we weren't running 4.0.3 , that's why the error was shown.
npx was running a cached copy of an earlier create-react-app version ( 4.0.1 in your original issue @peterbe) that then complained because it recognised there was a newer version available.
Lines 204 to 211 in 8bf050a
if ( latest && semver . lt ( packageJson . version , latest ) ) console . log ( ) ; console . error ( chalk . yellow ( `You are running \`create-react-app\` $ < packageJson . version >, which is behind the latest release ( $ < latest >).\n\n` + 'We no longer support global installation of Create React App.' ) ) ; mrmckeb commented Feb 25, 2021
I did some digging, and this may be an npm bug, as we did research this at the time and as I understood, both npx and yarn create use the latest version - using the cached version only if that is the latest version.
It looks like this is fixed in the latest releases of npm . If you can try that, and report back, that would be greatly appreciated!
This was the trail I took:
kvaropil commented Dec 8, 2020 •
Running on macOS Catalina 10.15.7
$ node -v >> v14.15.1
$ npm -v >> 6.14.8I am facing the same issue mentioned in the first post.
I have tried different versions of Node and NPM, npm uninstall -g create-react-app (although never installed CRA globally on my current machine), clear npm cache, reinstall the entire Node. My $ which create-react-app returns nothing, $ npm list -g --depth=0 returns
I am really out of ideas how to fix this issue.
Sverxsro4nik commented Feb 24, 2021
Many thanks. It helped. Launched
BenJenkinson commented Feb 24, 2021 •
I think it's very unreasonable to require latest release.
@Fnjn I don't think the purpose was to force you to use a latest version.
As far as I understand, there are issues that can occur if you run create-react-app from a global install. So the check is meant to detect that scenario and the error is to explain why and how to correct it.
But the check was written to check for when you're not running the latest version (which would occur in a "global" scenario); presumably on the assumptions that npx / npm init would always fetch and run the latest version, and if you weren't using the latest version you must be running a "global" install.
I think the CLI bug is that that assumption is wrong. As we've seen, npx and npm init can sometimes use a cached version of create-react-app that is then not the latest version, which triggers the error, which then contains advice for a scenario that isn't happening.
MahrezDev commented Dec 2, 2020
npm init -y
npx create-react-app project1salvadorbeltrandev commented Nov 27, 2020
Worked for me as well, thank you.
I solved this using the following command.
npm uninstall -g create-react-app
then
npm install -g create-react-app
Читайте также: