npm start error caused by webpack version - node.js

I am having a problem when executing the command npm start on recently react apps. I don't have much experience with node.js and didn't find the exact problem on the internet so decided to ask here.
Two days ago I started having a problem that npm start didn't work in any react app I created, this morning I even created a new one with npx create-react-app test, opened the project folder in VSCode and immediately executed npm start but got the same problem so I don't think it is something I messed up in the other apps.
The error I get is this
> sci-cal#0.1.0 start C:\Users\virgi\OneDrive\Documentos\VS_VSC\typescript_vsc\test
> 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.44.2"
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\virgi\node_modules\webpack (version: 5.52.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:
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 C:\Users\virgi\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! sci-cal#0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the sci-cal#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\virgi\AppData\Roaming\npm-cache\_logs\2021-09-16T11_48_33_404Z-debug.log
I already tried the first four steps but it didn't fix the issue and webpack is in the node_modules project folder.
I think that it may be an issue of the react version I am using not being updated and thus not recognizing webpack version 5.52.1 but as previously said, I don't have much experience with react and didn't find the exact same problem fix on the internet so I decided to ask here before doing anything else to prevent the problem from possibly getting worse.

Since you already tried the first 4 steps, you can try to browse to C:\Users\virgi and check if you have the node_modules folder here. Delete it and run npm start in your project again

Related

Unable to find expo in this project - have you run yarn / npm install yet? Npm has been installed, expo directory exists

My Expo project is pretty much 9999999% errors thus far, and it finally reached its climax when it decided to throw an error I've never heard of at me:
module not found: can't resolve '../utilities/platform'
I've never seen this, and I was explicitly working in an isolated styling file when it occurred. I deleted the file and the error persisted. Seeing that it was in node_modules, I figured that deleting node_modules would be helpful. It wasn't. I deleted the node_modules and tried to run npm i --save afterwards but it kept erroring out. I restarted my computer, deleted the new node_modules, and tried to run npm i --save yet again. This time I was greeted with this:
read-shrinkwrap This version of npm is compatible with lockfileVersion#1, but package-lock.json
was generated for lockfileVersion#2. I'll try to do my best with it!
npm ERR! Maximum call stack size exceeded
Now, I have a half(ish) completed node_modules, and whenever I try to run expo start, which I have about 700000000 times before this, it tells me this...
Unable to find expo in this project - have you run yarn / npm install yet?
Which, yes stupid I have my expo set up, and yes AGAIN, I just ran npm install about twenty-two times. So I have absolutely no idea what happened, why it happened, or how to fix whatever happened. If you can help me I will award you my first born but fair warning that might take another 20 years
Try to remove all react-native data folders from "%appdata%\Temp" and execute following commands:
cd android (if any)
gradlew clean
cd.. and remove the node_modules folder
npm cache clean --force
npm install
npm start -- --reset-cache

Npm start and Build is no longer working on my Windows

I have been using npm for months to build projects and it's suddenly stopped working 5 days ago on all my React projects.
Now, whenever I try to run npm start I get an error saying:
project name #0.1.0 start
react-scripts start
The system cannot find the path specified.
So, first I tried npm install again and then start but it didn't work so I tried npm cache clean and got an error saying:
npm ERR! As of npm#5, the npm cache self-heals from corruption issues...
and then the terminal told me to try npm cache clean --force. Then I got another error saying:
npm WARN using --force Recommended protections disabled.
I have also tried running npm cache verify and it didn't work. I even went as far as downloading and installing the latest version of node and still nothing.
and it's not just that i also tried doing "npm run build" on another app in another directory and it showed this
"amazon-clone#0.1.0 build
react-scripts build
The system cannot find the path specified."
I checked and I'm using NPM version 7.9.0
please I'm stuck and I don't know what to do about
I too faced this problem and I resolved this by,
Create a .env file in react project root directory.
Add this line SKIP_PREFLIGHT_CHECK=true.
It took a while but i found that running
"npm config set script-shell bash" on git bash
fix the issue but only on git bash

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

npm ERR! cb() never called in windows10

I was trying to run npm install inside the project folder but every time there is this error showing npm cb() never called.
I am using node version 10.16.2 and npm version 6.9.0 in windows 10
I have tried npm cache clean --force but that didn't help
E:\contribution\contribute-to-open-source>npm install
npm ERR! cb() never called!
npm ERR! This is an error with npm itself. Please report this error at:
npm ERR! <https://npm.community>
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\papun\AppData\Roaming\npm-cache\_logs\2019-08-10T03_51_20_512Z-debug.log
I had the same problems and lost hours trying to solve it :(.
But then i found out that my firm has installed some new kind of firewall with self signed certificate.
Quick solution was:
npm config set strict-ssl=false
After that everything started working without 'npm cb() never called' errors
I had faced the same issue, and i spend days to get a solution for the issue. In the end, i figured it out and it was an issue with my network.
Please verify your network connection and proxy settings.
In my case, I was using corporate proxy using a script. When i opened the pac file and get the proxy from there ( take XXX:XXX from the line return "PROXY XXX:XXX;";) and added to npm config proxy setting (npm config set proxy XXX:XXX), it started working and got resolved.
run this all issue will be solved..
npm install --global windows-build-tools
try to set your proxy using the commands
npm config set proxy http://proxy_host:port
npm config set https-proxy https://proxy_host:port
I have deleted all the node_modules, package-lock.json but still it was not working. For me the reason was, there were some modules that required relogin to install.
So, I deleted my node_modules, build and package-lock.json. and opened command prompt in admin mode.
Then went to the specific project path and logged-in to the components that require credentials.
1. npm login (root path of your react app)
2. type username as "<xxxxx>"
3. type password as "<yyyyy>" (won't be visible on console)
4. type email as "<zzzz>#<aaa>.com"
5. npm i
6. npm run build
It worked for me.
I also faced the same problem I deleted that file from
C:\Users\Harshk1311\AppData\Roaming\npm-cache\_logs
And problem solved
Double Check file name in terminal where error occured and delete file
i.e C:\Users\Harshk1311\AppData\Roaming\npm-cache_logs\2019-08-10T03_51_20_512Z-debug.log
Delete 2019-08-10T03_51_20_512Z-debug.log only this file .
Another possible reason that solved the problem in my case:
Missing MS VC Redistributable. For example if you are on a fresh new PC. In this case you could download the e.g. VC_redist.x64.exe and install it. You may need to restart the terminal before e.g. executing npm i again.
The Visual C++ Redistributable installs Microsoft C and C++ (MSVC) runtime libraries. These libraries are required by many applications built by using Microsoft C and C++ tools.

Cannot uninstall webpack from react-script

I was trying to make a todo-app in react, which is new to me. But after once installed webpack, npm start doesnt working. It gives me:
my-todo-react#0.1.0 start /home/hanna/Desktop/projects/my-todo-react
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.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/hanna/node_modules/webpack (version: 4.20.2)
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:
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 /home/hanna/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!
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! my-todo-react#0.1.0 start: react-scripts start
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the my-todo-react#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! /home/hanna/.npm/_logs/2018-10-02T10_39_06_361Z-debug.log
Create a .env file in the root directory of the project and add this line SKIP_PREFLIGHT_CHECK=true inside the file.
then try to run yarn start.
To solve this issue I had to uninstall webpack and webpack-dev-server from the node-modules folder and then install them again but with different versions.
Open cmd on the node-modules folder outside of your project folder
Uninstall webpack and webpack-dev-server:
npm uninstall webpack
npm uninstall webpack-dev-server
Delete the node-modules folder and the package-lock.json file from your project's folder.
Open the node-modules again
npm install webpack#4.19.1
npm install webpack-dev-server#3.1.9
Use this command on your project folder
npm install
It did the trick for me, hope it helps you too.
One solution I had was to go to my "Home" folder and delete the node_modules
folder and package-lock.json file.
Worked afterwards.
Since it looks like the project uses Create React App, Webpack is probably already a dependency in the package.json. So the easy way to install it is to just go to the project directory and type npm install (or yarn install) in the terminal.
If using the Webpack CLI causes errors, it's probably because there's a different version installed globally.
To uninstall it globally, type npm -g uninstall webpack.
I had similar problem today. I resolved with the following steps:
Execute npm ls webpack --> to find out that I have installed Webpack outside my folder ("like yours ... /home/hanna/node_modules/webpack).
Then cd into that location (/home/hanna/node_modules/) and execute npm install webpack#4.19.1.
That way I have the same version of Webpack like in my project folder.
After that, when I run npm start, it works fine.
Go to your project directory where you are running npm start and run the command
touch .env
If there is no pre-existing .env file in your project this will create it.
Got to .env file and add the following code (if you are on LINUX box you do this by typing nano .env otherwise just use a text editor.
SKIP_PREFLIGHT_CHECK=true
Save the file and try running npm start again.
This solution is exactly what is suggested in the error message and it worked for me
do this
first code in terminal this -->
yarn add --dev dotenv
create .env file in root directory then add below line in the .env file
SKIP_PREFLIGHT_CHECK=true
Go to /home/hanna and type npm i webpack#required_dependency. It should solve your problem.
If someone still facing this issue and uses yarn instead of npm can do (I am a mac user):
Open a terminal
Type yarn remove webpack
Come in to your project directory using your file explorer
Delete everything there
Open your code-editor
Delete hidden filers (ETC: .env or .gitignore files) if exists
In your project directory open a terminal and type npx
create-react-app . and hit enter.
And restart the app typing yarn start after download.
It worked for me. It downloaded the web pack which is needed from react-scripts.
I encountered the same issue and following worked for me:
Delete the node-modules folder and package-lock.json file
Downloaded and installed Node.js
npm install webpack#4.19.1
npm install webpack-dev-server#3.1.9
Deleted babel-eslint entry from package.json
Used this command on the project folder: npm install
Finally yarn start or npm start
I think if you have a webpack package installed globally it might cause such error. Removing it globally might solve the problem. That's what I did here and it works.
npm uninstall webpack
npm uninstall webpack-dev-server
Delete the node_modules folder and the package-lock.json file from your root directory
##thompsonmax##
Then you can now run your command to your app,
create-react-app react-app
Step 1: Create an .env file in the root directory
Step 2: add this line into your .env file: SKIP_PREFLIGHT_CHECK=true
Step 3:Again npm start
After a lot of trials, I found that the easiest solution is to install the required version of webpack in /home/hanna.
That is,
cd to /home/hanna
run npm i webpack#4.19.1
Then, the error will go away. Hope it helps.
Your problem is you installed webpack version: 4.20.2
You need to install an earlier version "webpack": "4.19.1"`
Your problem is you installed webpack version: 4.20.2
You need to install an earlier version "webpack": "4.19.1"` ..So
$npm uninstall -g webpack
and
$npm install -g webpack#4.19.1
Hope that helps
I think if you have a webpack package installed globally it might cause such error. Removing it globally might solve the problem. That's what I did here and it works.
Due to newer versions, this worked for me:
Open a terminal window (command prompt) on the node_modules folder outside of your project folder
Uninstall webpack and webpack-dev-server:
npm uninstall webpack
npm uninstall webpack-dev-server
Delete the node_modules folder and the package-lock.json file from your project's folder.
Open node_modules again
npm install webpack#4.28.3
npm install webpack-dev-server#3.1.14
Use this command in your project folder:
npm install
I couldn't find a way to uninstall the whole node module folder the only way is to delete the whole file using command line
rm -rf node_modules
npx create-react-app nameOfYourApp
find where is your nameOfYourApp and replace src folder with one from previous project
use new nameOfYourApp
If you have multiple node_modules folders with different versions of dependencies one may conflict with the other - do the following:
Follow steps 1-4 that are initially provided in project directory and commit updated changes locally~
i. Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.
ii. Delete node_modules in your project folder.
iii. Remove webpack from dependencies and/or devDependencies in the package.json file in your project folder.
iv. Run npm install or yarn, depending on the package manager you use.
Find the location of the node_modules folder that is not in your project folder ~ this line - (/home/hanna/node_modules/webpack)
Delete it
npm start
should work :)!
I also faced this issue. I had to install webpack#4.42.0 in the node_modules but after I installed webpack#4.42.0 there was an error displayed in the CMD:
`-- UNMET PEER DEPENDENCY webpack#4.42.0
npm ERR! peer dep missing: webpack#^5.1.0, required by terser-webpack-plugin#5.2.4
So installing webpack for node_modules didn't work. Then I used .env file to solve this.
First I typed npm add --dev dotenv in the project terminal.
Then I created the .env file and typed this code:
SKIP_PREFLIGHT_CHECK=true

Resources