App created with npx create-react-app failed to start, - javascript

Greatings,
a few months ago i created an app via create-react-app. This app did not run when i entered npm start. And i get the following error message:
react-scripts 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:
"babel-loader": "8.1.0"
Don't try to install it manually: your package manager does it automatically.
However, a different version of babel-loader was detected higher up in the tree:
/Users/kevinmotzkus/Documents/projects/node_modules/babel-loader (version: 8.0.6)
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 "babel-loader" 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:
5. If you used npm, install yarn (http://yarnpkg.com/) and repeat the above steps with it instead.
This may help because npm has known issues with package hoisting which may get resolved in future versions.
6. Check if /Users/kevinmotzkus/Documents/projects/node_modules/babel-loader is outside your project directory.
For example, you might have accidentally installed something in your home folder.
7. Try running npm ls babel-loader in your project folder.
This will tell you which other package (apart from the expected react-scripts) installed babel-loader.
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! womd#0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the womd#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! /Users/kevinmotzkus/.npm/_logs/2020-07-10T20_09_39_848Z-debug.log
I followed the steps, but it isn´t working. I dont know what to look for.
do i need to install package managements into the app folder? Im kinda new to react and coding so be patient and gentle please ^^
Im happy if you give me critic about my question too, is it understandable, do you need more or specific information?

You could delete the package-lock.json file and the node_modules folder and then run
npm install
Also, this is a pretty similar issue
Create React App requires a dependency: “babel-loader”: “8.1.0”

Related

Unable to Install and configure the MDX transformer plugin (and dependencies) in gatsby site

Goal: Trying to create a simple blog using Gatsby
Outcomes:
Expected Outcome: Things should go as defined in the tutorial guide
Actual Outcome: Getting Dependency tree error in step(s) & Also a warning message like 34 vulnerabilities (11 moderate, 23 high) whenever installing something using npm in this project
Approach: I am following the guide available here, & in Task install MDX transform plugin, getting the below error
Questions:
How do i resolve this particular dependency tree issue & Also in general how do i approach this kind(dependency tree issue) of errors in npm?
The warnings related to the vulnerable packages - How critical are those & How should it be handled ?
Command-used: npm install gatsby-plugin-mdx #mdx-js/mdx#v1 #mdx-js/react#v1
Output/Console Error:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: my-gatsby-site#1.0.0
npm ERR! Found: react#18.2.0
npm ERR! node_modules/react
npm ERR! react#"^18.1.0" from the root project
npm ERR! peer react#"^16.9.0 || ^17.0.0 || ^18.0.0" from gatsby-plugin-mdx#3.18.0
npm ERR! node_modules/gatsby-plugin-mdx
npm ERR! gatsby-plugin-mdx#"*" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react#"^16.13.1 || ^17.0.0" from #mdx-js/react#1.6.22
npm ERR! node_modules/#mdx-js/react
npm ERR! #mdx-js/react#"v1" from the root project
npm ERR! peer #mdx-js/react#"^1.0.0" from gatsby-plugin-mdx#3.18.0
npm ERR! node_modules/gatsby-plugin-mdx
npm ERR! gatsby-plugin-mdx#"*" 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 <home-folder>/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! <home-folder>/.npm/_logs/2022-07-06T15_46_56_149Z-debug-0.log
Updates:
Update 1:
After trying one of the suggestion given by the fellow stack-overflow site member, a new error is thrown! So ignoring the dependency tree issue with skip legacy tree is not working, Hence any more suggestion from any gatsby users!?
gatsby develop
ERROR #11901 COMPILATION
Failed to compile Gatsby files (Error):
Could not resolve module "#parcel/namer-default" from
"<home-folder>/codeSpace/siteByGatsby/sv3/my-gatsby-site/node\_modules/#gatsbyjs/parcel-namer-relative-to-cwd/lib/index.js".
not finished compile gatsby files - 0.778s
Not that "you should" normally do what i am about to suggest, but you can run:
npm install gatsby-plugin-mdx #mdx-js/mdx#v1 #mdx-js/react#v1 --legacy-peer-deps
Basically what this will do is tell npm that you wish to install peer dependencies, the reason this happens is because you are using React#18.2 in your project, but the packages you are trying to install are using a lower version of React. Thus, NPM is throwing you this error.
The reason why "you shouldn't" normally do this, is imagine theres a dependancy within a package that is flagged as vunerable, but you currently have a 'fixed' version of this installed. You would then be installing the peer dependency that could have a vulenarbility.
You can run the above code and be 'alright', its not a big deal that it is wanting to install lesser version of React.
But what you should also think about, is do you really need React#18.2, or could you use a downgraded version because, how likely are you to use any of the features that might be in the latest version release.
This is also a reason why a lot of developers don't just go and install the newest version of React when they are building projects, because you have to rely on packages that are maintained by either solo developers, or by a community of lovely people who are willing to help maintain a package to bring it up to speed with Reacts latest releases.
These are pretty much the main three things you can do:
You either install the legacy dependencies
You knock React down a version peg that is inline with the version required in the dependency tree for the packages you are looking to use
You find another package, or you take a look on their Github incase they have released a version, but not yet published this release to NPMjs yet
Hope this helps :)
Sidenote:
When migrating this project to a hosting provider, you will also need to tell them that you have packages that you have force installed with --legacy-peer-deps by either creating an environment variable for the site on the hosting providers platform, or with .npmrc file with the following:
legacy-peer-deps=true

create-react-app command failing at the very end, with errno -4058

I've been following a video course for full stack web development, and have gotten to the react part. The video course says that the create-react-app npm package can be used to readily and easily do an initial setup of a react app file hierarchy with all dependencies.
The method discussed in the course is to install the craete-react-app package globally using npm install -g create-react app, which I did. Then I should be creating the react app by using create-react-app my-project-name. When I launch this command, i get an output like this: Screenshot of error. In text:
Creating a new React app in E:\University\Learning material\Web
Development\Udemy - The Complete Web Developer in 2021 Zero to Mastery
2021-4\19. React.js, React Hooks, Redux (Hooks and Redux videos moved
to end of course!)\exercise 1\robofriends.
Installing packages. This might take a couple of minutes. Installing
react, react-dom, and react-scripts with cra-template...
npm ERR! code ENOENT npm ERR! syscall spawn
C:\WINDOWS\system32\cmd.exe npm ERR! path E:\University\Learning
material\Web Development\Udemy - The Complete Web Developer in 2021
Zero to Mastery 2021-4\19. React.js, React Hooks, Redux (Hooks and
Redux videos moved to end of course!)\exercise
1\robofriends\node_modules\babel-runtime\node_modules\core-js npm ERR!
errno -4058 npm ERR! enoent spawn C:\WINDOWS\system32\cmd.exe ENOENT
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\Amin\AppData\Local\npm-cache_logs\2021-05-02T16_25_06_903Z-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 robofriends/ from
E:\University\Learning material\Web Development\Udemy - The Complete
Web Developer in 2021 Zero to Mastery 2021-4\19. React.js, React
Hooks, Redux (Hooks and Redux videos moved to end of course!)\exercise
1 Done.
The log file mentioned in the error has no extra information as far as I can see, only the same error message exactly replicated in a log file along with the preceding installation steps. Just to be sure, I've made 3 pastebins to contain the gigantic log file here: Part 1 Part 2 Part 3
Methods I've tried to resolve the issue (And a combination of some) :
The good old restart your computer!
Clearing the npm cache by usingnpm cache clear -f
Uninstalling create-react app, and reinstalling
Uninstalling create-react-app and using npx create-react-app robofriends to first install the package and then create the app folder right after
Opening my command line in administrator mode
Any help or guidance on the issue will be greatly appreciated. Thank you.
Also, it might help to mention that I am using Windows 10 64bit.
It looks like there is a problem with your path (special characters etc.). If I recreate your exact path on my drive, I fail to create a react-app as well. However, if you change your directory to another one and try again it should work!

React npm start causes react web app to start the same project from any directory (even when that project is deleted)

I'm sorry this is a little bit long..I'd really appreciate any help! (And if this is a repeat qn, I'd really appreciate it if you'd let me know! Thank you!!)
There is probably a problem with my npm globally. The first time an error occurred when I tried to use node-sass in my react app, my code editor flagged this error:
Fangs-MacBook-Pro:react_frontend fangran$ npm start
> react_frontend#0.1.0 start /Users/fangran/Documents/microservices-test/react_frontend
> react-scripts 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:
"webpack-dev-server": "3.11.0"
Don't try to install it manually: your package manager does it automatically.
However, a different version of webpack-dev-server was detected higher up in the tree:
/Users/fangran/Documents/node_modules/webpack-dev-server (version: 3.10.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-dev-server" 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:
5. If you used npm, install yarn (http://yarnpkg.com/) and repeat the above steps with it instead.
This may help because npm has known issues with package hoisting which may get resolved in future versions.
6. Check if /Users/fangran/Documents/node_modules/webpack-dev-server is outside your project directory.
For example, you might have accidentally installed something in your home folder.
7. Try running npm ls webpack-dev-server in your project folder.
This will tell you which other package (apart from the expected react-scripts) installed webpack-dev-server.
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! react_frontend#0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the react_frontend#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! /Users/fangran/.npm/_logs/2020-08-31T02_45_12_620Z-debug.log
So I followed these suggested instructions and the error was still there. Then, running npm ls webpack-dev-server, I got
react_frontend#0.1.0 /Users/fangran/Documents/microservices-test/react_frontend
└─┬ react-scripts#3.4.3
└── webpack-dev-server#3.11.0
The weird thing is, running npm ls webpack-dev-server in any other directory resulted in it showing the webpack-dev-server version of another already deleted project directory (nba-tutorial has been deleted from my Documents folder). Here's some examples:
Fangs-MacBook-Pro:microservices-test fangran$ npm ls webpack-dev-server
nba-tutorial#0.1.0 /Users/fangran/Documents
└─┬ react-scripts#3.4.1
└── webpack-dev-server#3.10.3
Fangs-MacBook-Pro:microservices-test fangran$ cd ..
Fangs-MacBook-Pro:Documents fangran$ npm ls webpack-dev-server
nba-tutorial#0.1.0 /Users/fangran/Documents
└─┬ react-scripts#3.4.1
└── webpack-dev-server#3.10.3
I then changed my npm config prefix to /usr/local/lib/node_modules by running
fangran#Fangs-MacBook-Pro ~ % npm config set prefix /usr/local/lib/node_modules
But nothing got fixed. At this point i'm pretty confused about what's going on. I've tried uninstalling and reinstalling node as well but things still remained the same. May I ask how I can successfully run npm start in my microservices-test/react_frontend directory please? And what's going on?
Thank you for your time reading this!

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

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:
"babel-loader": "8.0.5"
Don't try to install it manually: your package manager does it automatically.
However, a different version of babel-loader was detected higher up in the tree:
/Users/moeismail/node_modules/babel-loader (version: 8.0.6)
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:
Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.
Delete node_modules in your project folder.
Remove "babel-loader" from dependencies and/or devDependencies in the package.json file in your project folder.
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:
If you used npm, install yarn (http://yarnpkg.com/) and repeat the above steps with it instead.
This may help because npm has known issues with package hoisting which may get resolved in future versions.
Check if /Users/moeismail/node_modules/babel-loader is outside your project directory.
For example, you might have accidentally installed something in your home folder.
Try running npm ls babel-loader in your project folder.
This will tell you which other package (apart from the expected react-scripts) installed babel-loader.
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! exported-from-react-studio#0.0.1 start: PORT=3000 react-scripts start
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the exported-from-react-studio#0.0.1 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! /Users/moeismail/.npm/_logs/2020-01-11T14_27_54_274Z-debug.log

npm wont start a react app, requires a dependency: "webpack-dev-server": "3.1.14"

I am trying to create a new react-app and start it, I have created react apps before with no errors but this time when i npm start i get this error
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:
"webpack-dev-server": "3.1.14"
Don't try to install it manually: your package manager does it
automatically.
However, a different version of webpack-dev-server was detected higher up
in the tree:
C:\Users\ashraf\node_modules\webpack-dev-server (version: 3.1.9)
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-dev-server" 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:
5. If you used npm, install yarn (http://yarnpkg.com/) and repeat the
above steps with it instead.
This may help because npm has known issues with package hoisting which may
get resolved in future versions.
6. Check if C:\Users\ashraf\node_modules\webpack-dev-server is outside
your project directory.
For example, you might have accidentally installed something in your home
folder.
7. Try running npm ls webpack-dev-server in your project folder.
This will tell you which other package (apart from the expected react-
scripts) installed webpack-dev-server.
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! learnreact#0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the learnreact#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\ashraf\AppData\Roaming\npm-cache\_logs\2019-02-
04T20_36_39_924Z-debug.log
PS C:\Users\ashraf\Desktop\Files\LearnReact\learnreact>
i have tried all the steps in detail in the error log but its still not working, any thoughts on what is causing this error? Thanks in advance
It seems like you want to depend on webpack-dev-server inside your local project.
Perhaps you need to run npm install in your project, instead of your ~ home directory?
from your output, notice these lines.
However, a different version of webpack-dev-server was detected higher up
in the tree:
C:\Users\ashraf\node_modules\webpack-dev-server (version: 3.1.9)
...
6. Check if C:\Users\ashraf\node_modules\webpack-dev-server is outside
your project directory.
For example, you might have accidentally installed something in your home
folder.
so I would
cd ./my-project
npm i
Did you install webpack-dev-server on its own? It seems it has been installed either by you or by another project install. Webpack is for your local development environment so the other install is close enough to your project to interfere with the copy that react is trying to install in your project folder. Steps 1-4 in your error message should resolve your issue. If you have done that and its still not working, did you get different error messages with your next attempt to install your react package?
I have faced the same issue and this method worked for me.
Do follow the steps:
Start terminal from the desktop and write this command:
npm uninstall webpack-dev-server
This will uninstall webpack-dev-server package globally from you node modules.
Go back to you the terminal of your project and install webpack-dev-server package:
npm install webpack-dev-server#version
Note: The version part (above) should equal the versions asked for in the error message.
npm install webpack-dev-server
Now start npm:
npm start
This error mostly occurs when you have created your project using the
npx create-react-app command instead of the npm create-react-app command.

Categories

Resources