I am currently having trouble solving dependency tree error with React 18. Initially, I couldn't start a new react project with npx-create-react-app my-app (a template was not provided). I fixed that and can now start a new project, but I have two other react apps that I cannot get to start up.
The first one is a portfolio react template that I downloaded. I opened it up and ran npm start in the terminal with no luck (attached is the dependency tree error message).
These are the steps I took to try to fix it:
I deleted all react and node folders that were dowloaded on my Mac (outside of the directory).
Ran npm install --save --legacy-peer-deps
Ran rm -rf node_modules
Ran npm cach clean --force
I removed package.lock.json
I changed these scripts in package.json to updated versions
nodemon: 2.0.16
react: 18.1.0
react-scripts: 5.0.1
React-dom: 18.1.0
When I then run npm start I get the dependency errors. I would appreciate any help and advice! Thanks so much![!dependency errors]
I've scoured the internet for an answer to this, and haven't found anything yet that works. I'm new to using React, but my friend asked for help with some CSS so I cloned his React project from github (the React app is successfully online and he can work on it locally). Repo is here: https://github.com/brandonkun5/TrueAlpha
When I ran npm start, it told me I had no module 'react-scripts', so I ran npm install react-scripts
Now, when I run npm start, I get the following message:
internal/modules/cjs/loader.js:638
throw err;
Error: Cannot find module './common'
So far, I've tried:
npm del package.json
npm del node_modules
npm install
Moving the folder into a different location
Searching the code for 'Require ('common')" and 'Require ('./common')
Updating to the last node version
and nothing has worked yet. Any ideas on what could be causing this error?
The file common.js is missing in node_modules/debug/src/common.js. I copied it from another React project of mine and run npm start in the console and then it worked. Try to copy that file from the path above to same path in this project and it should work. Second option is to run "npm install debug" and file will installed and debug folder will be updated.
When I start to create a new react app, and run -npx create-react-app my-app, I see after installing reactand other modules, it is deleting all file folder. Below is the code details found in cmd.
...
├─ react-scripts#3.0.0
└─ react#16.8.6
Done in 422.17s.
Error: EPERM: operation not permitted, open 'C:\Users\lenovo.yarnrc'
Aborting installation.
yarnpkg add --exact react react-dom react-scripts --cwd D:\test\project\react\my-app has failed.
Deleting generated file... node_modules
Deleting generated file... package.json
Deleting generated file... yarn.lock
Deleting my-app/ from D:\test\project\react
Done.
D:\test\project\react>
Screen-shot of Command line tool as
CMD lines after create-new-app
System And version:
Windows10
node#10.15.3
npm#6.9.0
yarn#1.15.2
npx#6.9.0
Check out the solutions provided for npm - EPERM: operation not permitted on Windows
here
If nothing works try downloading over different internet connection as well.
Please remove any global installs with one of the following commands:
npm uninstall -g create-react-app
yarn global remove create-react-app
The latest instructions for creating a new app can be found here:
https://create-react-app.dev/docs/getting-started/
Below is the error message;
Aborting installation.
npm install --save --save-exact --loglevel error react react-dom react-scripts has failed.
Deleting generated file... node_modules
Deleting generated file... package.json
Deleting firstapp / from D:\Atom Projects\NewProject
Done.
I have checked the path environmental variable path, it seems to be perfect.
Deleting the "Ansicon Entries" in the Registry
HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun
helped me solving the issue. I followed the solution posted in
https://github.com/cmderdev/cmder/issues/121
I'm trying to create my first React Native app for Android using the instructions on https://facebook.github.io/react-native/docs/getting-started.html. After setting up the dependencies and connecting my Android device, I ran
react-native init app
cd app
react-native run-android
This starts the React Packager, which fails to bundle with this error:
error: bundling failed: "TransformError: /Users/luky/dev/app/index.android.js: Unexpected token ) (While processing preset: \"/Users/luky/dev/app/node_modules/babel-preset-react-native/index.js\")"
I am using:
OSX El Capitan 10.11.6.
node version 6.9.2
react-native version 0.47.1.
I pushed my generated project, including node_modules, to Github in case it helps: https://github.com/luky1971/react-native-app
Does anyone know why I might be getting an Unexpected token error? Any help would be greatly appreciated!
I got the same thing, it looks like the latest version of the babel preset for react native has some bugs (version 3.0.0). I went into my package.json and replaced the latest version with this:
"babel-preset-react-native": "2.1.0".
then I deleted the node_modules directory and ran npm install and it worked.
Install babel-preset-react-native#2.1.0 and run the project.
In the current project, do this...
yarn remove babel-preset-react-native
yarn add babel-preset-react-native#2.1.0
This worked for me, I hope it will for you too.
You can find more information about the error here https://github.com/facebook/react-native/issues/15513#issuecomment-322824346
Try deleting the .babelrc file in the root directory. Or rename it. Then re-run the "react-native run-android" command. This worked for me. Good luck.
Looking for JS files in
/Users/admin/Desktop/CoinMarketCap
React packager ready.
Loading dependency graph, done.
Bundling `index.ios.js` [development, non-minified, hmr disabled] 0.0% (0/1), failed.
error: bundling failed: "TransformError: /Users/admin/Desktop/CoinMarketCap/index.ios.js: Unexpected token ) (While processing preset: \"/Users/admin/Desktop/CoinMarketCap/node_modules/babel-preset-react-native/index.js\")"
iMac-D001:CoinMarketCap admin$ react-native --v
react-native-cli: 2.0.1
react-native: 0.47.1
Fixed it for me:
https://github.com/facebook/react-native/issues/15545
iMac-D001:CoinMarketCap admin$ npm uninstall babel-preset-react-native
iMac-D001:CoinMarketCap admin$ npm install babel-preset-react-native#2.1.0
I cloned your project. It is working fine. You can delete node_modules folder, then npm_install. It will work fine.
Try to set a new project, choosing the version of react-native as below:
react-native init --version="0.55.0" MyNewApp
Go to the new project directory.
CD project_name
Open the app in android studio. Open the AVD manager emulator and choose the virtual device. Then execute this command back there on the prompt:
react-native run-android
This worked for me. Hope it can help you too.
It could also be because of a dependency that you're using and needs to be put in the preset of your babel.config.js
e.g. I ws using expo, then ejected. And one of the dependency was react-native-paper for which I had to change the babel.config.js file to get it working.