This question already has an answer here:
Yarn test failing - Network request failed
(1 answer)
Closed 5 years ago.
created a react project using create-react-app however when I go to run yarn test to see if the initial tests pass I get
/home/afenwick/Development/road-to-react-learning/node_modules/react-scripts/scripts/test.js:22
throw err;
^
TypeError: Network request failed`
error Command failed with exit code 1.
If I set up a brand new app it works totally fine, have not made any changes to App.test.js, just trying to run the default test. yarn start works fine, spins up my app in the browser.
Have tried deleting node_modules
Also tried npm install instead and npm run tests but that doesnt install my dependencies and then also errors the tests.
OS: Antergos Linux
Github repo: https://github.com/Fenwick17/road-to-react-learning
Stepped through my commits to locate the issue, and appears to be caused in https://github.com/Fenwick17/road-to-react-learning/commit/4b6069181a39861e531b550ebb8689695db042bb so I will work through the changes to rectify.
I also ran into this problem when following the book entitled "The Road to Learn React" and I think that the one causing this error is the part where fetch is called. The book forgot to include an import for fetch which is this one:
import fetch from 'isomorphic-fetch'
Then, it solves my problem like a charm. Hope this help.
Related
this problem occurred after deploying sanity to my project(I don't know if its the source of the problem but just wanted to share it.)
[This is what I see in the emulator]
(https://i.stack.imgur.com/otbGz.png)
and the following is what appears in the terminal:
Error: Duplicated files or mocks. Please check the console for more info
at setModule (/home/faisalmwy/development/react-native/food-delivery/node_modules/metro-file-map/src/index.js:553:17)
at workerReply (/home/faisalmwy/development/react-native/food-delivery/node_modules/metro-file-map/src/index.js:624:9)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Promise.all (index 27260)
at /home/faisalmwy/development/react-native/food-delivery/node_modules/metro-file-map/src/index.js:395:22
at DependencyGraph.ready (/home/faisalmwy/development/react-native/food-delivery/node_modules/metro/src/node-haste/DependencyGraph.js:94:5)
at Bundler.ready (/home/faisalmwy/development/react-native/food-delivery/node_modules/metro/src/Bundler.js:75:5)
at IncrementalBundler.ready (/home/faisalmwy/development/react-native/food-delivery/node_modules/metro/src/IncrementalBundler.js:327:5)
at Server.ready (/home/faisalmwy/development/react-native/food-delivery/node_modules/metro/src/Server.js:1247:5)
I've searched for this problem before, some said delete the package-lock.json and node_modules, but it didn't work. others said reinstall npm all together. that didn't work also. I also tried running the app on a different localhost that usual, since sometimes me and a friend of mine connect in the same time.
Have you tried to stop the application and do the below process:
cd android and gradlew clean
remove node_modules and package-lock.json
run npm i
also remove application from simulator or from your device
rerun application
Disclaimer: this is my first question on Stack Overflow, so apologies if it's not formatted correctly. Please let me know how I can improve it or if more details are needed.
I tried to install styled-components for my React app with the following command npm install --save styled-components.
Before I did this, my server started up just fine with npm start.
After install, React tries to start up the development server but it stops and returns the following errors:
cacheEntry.sizeOnlySource = new SizeOnlySource(size);
TypeError: SizeOnlySource is not a constructor
at updateFileWithReplacementSource (project-directory/node_modules/webpack/lib/Compiler.js:756:37)
at updateWithReplacementSource (project-directory/node_modules/webpack/lib/Compiler.js:738:8)
at processMissingFile (project-directory/node_modules/webpack/lib/Compiler.js:801:8)
at project-directory/node_modules/webpack/lib/Compiler.js:843:10
at Immediate.<anonymous> (project-directory/node_modules/memfs/lib/volume.js:698:17)
Initially, I tried uninstalling the styled-components package. Same errors. Then, I tried updating webpack with npm update webpack.
I googled the errors but they were all for problems that seemed unrelated or that are now fixed.
Support Webpack 4.29.0 breaking change
output.futureEmitAssets option breaks compatibility with source map upload plugins
library target umd - Uncaught TypeError: x is not a constructor
I did come across a post on Stack Overflow explaining that --save is no longer necessary as of npm version 5.0.0. Perhaps it's the source of the error?
Note that I installed the styled-components package on a separate branch of my project, but the server still won't start when I switch to the main branch and I'm getting the same errors.
Honestly, I have no idea what's going wrong or how to fix it. Any help or guidance would be greatly appreciated.
Edit: before the Starting development server... line I get after running npm start, there's some kind of message about webpack being deprecated. I hadn't noticed that before, but it flashes by too quickly for me to read it and I can't scroll up to see the message. I created a new React project from scratch to see if the server would start. It does, but I'm still getting the aforementioned messages.
I'm new to programming, so please be gentle.
When I use 'npm start' to view my react app in local host it won't compile. I get an error message, 'Cannot find module './cli-engine'. That was not the case until today.
I suppose this file was in node_modules until recently? How can I restore my development environment to normal without breaking anything?
Here's the full error message:
Cannot find module './cli-engine'
Require stack:
- /Users/louysgackstetter/Desktop/Portfolio/Dominion/dominion/node_modules/react-scripts/node_modules/eslint/lib/api.js
- /Users/louysgackstetter/Desktop/Portfolio/Dominion/dominion/node_modules/eslint-webpack-plugin/dist/getESLint.js
- /Users/louysgackstetter/Desktop/Portfolio/Dominion/dominion/node_modules/eslint-webpack-plugin/dist/linter.js
- /Users/louysgackstetter/Desktop/Portfolio/Dominion/dominion/node_modules/eslint-webpack-plugin/dist/index.js
- /Users/louysgackstetter/Desktop/Portfolio/Dominion/dominion/node_modules/eslint-webpack-plugin/dist/cjs.js
- /Users/louysgackstetter/Desktop/Portfolio/Dominion/dominion/node_modules/react-scripts/config/webpack.config.js
- /Users/louysgackstetter/Desktop/Portfolio/Dominion/dominion/node_modules/react-scripts/scripts/start.js
UPDATE: npm install did not fix the issue. Or rather, it did, I no longer got the error described above, but I got a different "Cannot find module" error instead. Ultimately I created a completely new react-redux app using the create-react-app command and moved my source code over. Took me 10 minutes, solved the problem like a charm.
You can try npm install, and see if that resolves the problem.
Here is explained everything you need to know about it:
What's the difference between dependencies, devDependencies and peerDependencies in npm package.json file?
I am trying to start up a react app. After cloning the code from github, running yarn install I ran yarn start and got the following error:
yarn run v1.22.10
$ cross-env HTTPS=true react-scripts start
Unexpected identifier
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
The authors of the app don't know what might be wrong (it's working for them). I tried creating another app with create react app and that started up fine for me. I am not sure where to start looking as there is no indication as to where the "unexpected identifier" might be located or what it might be. Any ideas on what I might want to check or try? I am on MacOS Catalina.
I figured it out eventually. I tried running build and it failed on syntax error in one of the .js files (a missing comma). Once that was fixed the start ran too. If the start command returned the same informative error the build did it would have saved me hours :)
https://github.com/StephenGrider/UpStarMusic/
I cloned the above git repository and was trying to run it after installing dependcies using npm run start
.There is only connection refused error in electron console and the webpack never compiles until the window is closed and once its closed the webpack compiles successfully.
I don't know react was following a tutorial and this was related to MongoDb and for that the tutor was using a react node template to display the data
but am stuck as I cannot move and tried contacting the tutor but he is not responding and after checking git many had this issue .