npm start not working due to webpack issue - node.js

I had installed expo globally to learn react-native seeing a tutorial.
Now when I'm trying to make a new react app and run npm start I'm getting the following message.
yarn start
yarn run v1.22.4
$ 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": "4.42.0"
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:
/home/nikunj/node_modules/webpack (version: 4.43.0)
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:
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 /home/nikunj/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!
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
I tried several approaches to solve the problem.
Firstly i followed the first 4 steps in the error message but they did'nt work out as when i did
npm ls webpack
it returned
/home/nikunj
└─┬ expo-cli#3.24.2
└─┬ #expo/xdl#57.9.31
├─┬ #expo/webpack-config#0.12.25
│ └── webpack#4.43.0 deduped
└── webpack#4.43.0
Then I uninstalled expo-cli globally using
yarn global remove expo-cli
but even if i do that it is still giving me the same tree for npm ls webpack.
I also tried doing npm rm home/nikunj/expo-cli#3.24.2 but that is not solving the problem as still i get the same tree on npm ls webpack

Related

Facing an issue after cloning React repo

HI there I'm facing an issue after cloning a react repo(attached)-
PS C:\Users\User\Desktop\gfolio> npm start
gfolio#1.0.0 start
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:
C:\Users\User\node_modules\webpack-dev-server (version: 3.11.1)
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 "webpack-dev-server" 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 C:\Users\User\node_modules\webpack-dev-server is outside your project directory.
For example, you might have accidentally installed something in your home folder.
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!
I tried to fix it through the above method but not working,

How do I install a dependency on react?

I am new to react, I am setting up a new react-app that uses jest for UnitTesting, I have installed it and have now created the react app. It usually just launches the app to my browser on localhost, however, I am now getting this error:
Debugger attached.
Debugger attached.
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:
"jest": "26.6.0"
Don't try to install it manually: your package manager does it automatically.
However, a different version of jest was detected higher up in the tree:
C:\Users\tomas\OneDrive\Área de Trabalho\Gifermo2-react\gifermo2\node_modules\jest (version: 26.6.3)
I have tried to reinstall node_modules and reinstall jest.
I have also run npm ls jest which gives the following output.
gifermo2#0.1.0 C:\Users\tomas\OneDrive\Área de Trabalho\Gifermo2-react\gifermo2
├── jest#26.6.3
└─┬ react-scripts#4.0.2
├─┬ jest-watch-typeahead#0.6.1
│ └── jest#26.6.3 deduped
└── jest#26.6.0
I also get these steps to follow, which I have but nothing seems to work.
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 "jest" 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\tomas\OneDrive\Área de Trabalho\Gifermo2-react\gifermo2\node_modules\jest is outside your project directory.
For example, you might have accidentally installed something in your home folder.
7. Try running npm ls jest in your project folder.
This will tell you which other package (apart from the expected react-scripts) installed jest.
If nothing else helps, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
P.S. We know this message is long but please read the steps above :-) We hope you find them helpful!
Waiting for the debugger to disconnect...
Waiting for the debugger to disconnect...
npm ERR! code 1
npm ERR! path C:\Users\tomas\OneDrive\Área de Trabalho\Gifermo2-react\gifermo2
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c react-scripts start
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\tomas\AppData\Local\npm-cache\_logs\2021-02-15T23_40_56_648Z-debug.log
Waiting for the debugger to disconnect...
I have googled everything but can't seem to find an answer, I am guessing that there is some conflict and I am using two different JEST versions, but on my package.json, I don't even have the jest dependecy.
Any ideas?
I just solved it.
I have seen many people saying to reinstall the node_modules, that, unfortunately, did not work for me, here is listed what I have tried to do:
Deleting the package-lock.json
Deleting node_modules
Removing jest from the dependencies and devDependencies
Running npm install (to install the node_modules again)
None of that worked for me. What I did was, I removed jest from my computer, the whole app.
Go to your cmd and type "npm rm jest", which should seal the deal. After that, I ran "npm install" inside my project on VSCode "ctrl + j" to open the terminal, then just went with "npm start" and it is now working.
I am guessing that will also work if you get the same problem with other dependencies like Babel or something (I'm just guessing though, I am no expert in react or node).
Best of luck to anyone who is facing the same problem

React project dependency error while adding webpack

i have installed webpack with below command
yarn add webpack --dev
and after i ran yarn start command inside my react app folder
D:\Workspace\fuel-man-ui\fuel-man-ui>yarn start
Getting below error.
yarn run v1.19.0 $ 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": "4.29.6"
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:
D:\Workspace\fuel-man-ui\fuel-man-ui\node_modules\webpack (version:
4.41.0)
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 "webpack" 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 D:\Workspace\fuel-man-ui\fuel-man-ui\node_modules\webpack is outside
your project directory.
For example, you might have accidentally installed something in your home folder.
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!
error Command failed with exit code 1. info Visit
https://yarnpkg.com/en/docs/cli/run for documentation about this
command.
i have deleted node_modules from my project and devdependencies, also i have removed global node_modules and cache. still getting same error.
I ran npm ls webpack and got below tree
fuel-man-ui#0.1.0 D:\Workspace\fuel-man-ui\fuel-man-ui
+-- react-scripts#3.0.1
| `-- webpack#4.29.6
| `-- webpack#4.41.0 extraneous
`-- webpack#4.41.0
npm ERR! extraneous: webpack#4.41.0 D:\Workspace\fuel-man-ui\fuel-man-ui\node_modules\react-scripts\node_modules\webpack\node_modules\webpack
The react-scripts package provided by Create React App requires a
dependency:
"webpack": "4.29.6"
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:
In project root delete node_modules and yarn.lock. In package.json remove webpack from the dependencies and run yarn again.
If you want to modify webpack.config for this project you can run yarn eject from here on you are responsible for the webpack.config so it will be harder to update react scripts.
If you don't want to be responsible for the webpack.config you could try to use react-app-rewired an article on this is here
You should create .env file in the root (not inside src folder) and add SKIP_PREFLIGHT_CHECK=true
Then you can use yarn start or npm start. It works!
Yesterday I had the same issue. In my case it turned out, that I had two installations of node (one using brew, one using downloaded dmg file). It helped when I removed the one installed via brew.
The file .env with added SKIP_PREFLIGHT_CHECK=true

Cannot start npm/yarn

I decided to create React app under Linux and I've used those commands:
npm install -g create-react-app
create-react-app my_app_name
npm start
At this point I've recieved message:
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": "4.19.1"
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:
/home/ktw/node_modules/webpack (version: 4.24.0)
Manually installing incompatible versions is known to cause hard-to-debug issues.
If 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:
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 /home/ktw/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.
I've done literally every step from this list but unfortunately - with no results.
I've already tried:
chown -R user: node_modules,
npm cache clean --force,
rm -rf node_modules && rm ./package-lock.json && npm install
and I have no idea what is going on.
Do you guys have any idea how to fix that?
It looks like you may have forgotten to do Step #3: Remove "webpack" from dependencies and/or devDependencies in the package.json file in your project folder.
If you are doing the steps as you outline above, when you do npm install again, because Webpack is still in your package.json, it'll reinstall and continue the issue.

path is also the name of a node core module

I've just got back into node after a few months, and I'm a bit hazy on what I'm doing
I updated npm, node and gulp. My gulp file seems to work, but I just went to install gulp-compile-handlebars but I get the following:
Cooldude-MacBook-Air:_overlay cooldude$ sudo npm install --save-dev gulp-compile-handlebars
Password:
npm WARN package.json path#0.4.9 path is also the name of a node core module.
gulp-compile-handlebars#0.2.0 node_modules/gulp-compile-handlebars
├── through2#0.4.2 (readable-stream#1.0.27-1, xtend#2.1.2)
└── handlebars#2.0.0-alpha.4 (optimist#0.3.7, uglify-js#2.3.6)
Cooldude-MacBook-Air:_overlay cooldude$ ls
gulpfile.js.old node_modules src
I've not seen this before - what should I do to fix this?
This is not due to the gulp-compile-handlebars module since he has (and none of it's dependencies) no call to the path module.
I think that you have directly in the package.json of your project a reference to the path dependency that you need to remove because this is now a core module, so you don't have to put it in the dependencies of your project.
If it's not referenced, it certainly means that one of your dependencies has the path dependency. You can't do anything about that (expect a PR or an issue on the repo if available).
By the way it's just a Warning npm shows you, not an error so don't need to worry about that.

Resources