Failed to load configuration of my react native project - reactjs

./gradlew clean command in the android directory has issues too. I've tried downgrading the npm version but no help. Any ideas?
Below is the log I get when I run npx react-native run-android:
error Failed to load configuration of your project.
Error: Cannot find module '...\node_modules\json-parse-better-errors\index.js'. Please verify that the package.json has a valid "main" entry
at tryPackage (internal/modules/cjs/loader.js:320:19)
at Function.Module._findPath (internal/modules/cjs/loader.js:533:18)
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:875:27)
at Function.Module._load (internal/modules/cjs/loader.js:745:27)
at Module.require (internal/modules/cjs/loader.js:961:19)
at require (internal/modules/cjs/helpers.js:92:18)
at Object.<anonymous> (D:\projects\Beauty\node_modules\parse-json\index.js:3:18)
at Module._compile (internal/modules/cjs/loader.js:1072:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
at Module.load (internal/modules/cjs/loader.js:937:32)
Environment:
OS: Windows 10
react native: 0.65.1
Node: 14.17.4
npm: 7.23.0

use this command for installing the node module first
npm install --force
after that use
npx react-native run-android
for running the project

Happened to me earlier today because of mixing between npm and yarn package managers, a simple npm install solved this. No need to include --force flag.

I got this in an nx monorepo only for a specific app (but not others). None of the above methods worked for me. Finally figured this -
TLDR;
This is not the actual error (you probably guessed this). This error message comes from node_modules/#react-native-community/cli/build/index.js OR node_modules/react-native/node_modules/#react-native-community/cli/build/index.js.
To be sure, you can run this in node_modules directory: find . -name '*.js' -print0 | xargs -0 grep "Failed to load configuration of your project"
2. Edit these files to print the underlying error.
} catch (error) {
/**
* When there is no `package.json` found, the CLI will enter `detached` mode and a subset
* of commands will be available. That's why we don't throw on such kind of error.
*/
if (error.message.includes("We couldn't find a package.json")) {
_cliTools().logger.debug(error.message);
_cliTools().logger.debug('Failed to load configuration of your project. Only a subset of commands will be available.');
} else {
//---> ***** Print the underlying error!
console.log('=============>', error);
throw new (_cliTools().CLIError)('Failed to load configuration of your project.', error);
}
}
For me, this printed: =============> [CLIError: Node module directory for package react-native-animated-pagination-dots was not found]
All I had to do fix it was yarn add react-native-animated-pagination-dots. If only CLI had printed this underlying error, it would have saved me several hours! :-/
Longer explanation
When upgrading my monorepo, I somehow landed in a situation where one of the packages got removed from my packages.json, presumably because yarn couldn't resolve it (in my case this package was react-native-animated-pagination-dots). Then the app which had this dependency started getting this error, the other app didn't.

Related

failed to load config from C:\Users\92311\Videos\demo\vite.config.ts on run demo dev command in React Admin

`C:\Users\92311\Videos\demo>npm run dev
> demo#4.0.0 dev
> vite
failed to load config from C:\Users\92311\Videos\demo\vite.config.ts
error when starting dev server:
Error: ENOENT: no such file or directory, scandir 'C:\Users\92311\packages'
at Object.readdirSync (node:fs:1072:3)
at Object.<anonymous> (C:\Users\92311\Videos\demo\vite.config.ts:37:34)
at Module._compile (node:internal/modules/cjs/loader:1108:14)
at Object._require.extensions.<computed> [as .js] (file:///C:/Users/92311/Videos/demo/node_modules/vite/dist/node/chunks/dep-5605cfa4.js:63154:24)
at Module.load (node:internal/modules/cjs/loader:988:32)
at Function.Module._load (node:internal/modules/cjs/loader:828:14)
at Module.require (node:internal/modules/cjs/loader:1012:19)
at require (node:internal/modules/cjs/helpers:93:18)
at loadConfigFromBundledFile (file:///C:/Users/92311/Videos/demo/node_modules/vite/dist/node/chunks/dep-5605cfa4.js:63162:21)
at loadConfigFromFile (file:///C:/Users/92311/Videos/demo/node_modules/vite/dist/node/chunks/dep-5605cfa4.js:63020:34)
`
When i pull the demo from react-admin repo and After install dev dependencies and hit npm run dev i found this error im expecting to start
OS:Windows 11
NodeVersion : 14.10.0 (also tried till with latest version also).
So make commands is not working in windows for me what i did is
yarn install
on main/ root directory after that goes into each packages folder and run
yarn build
this what a make file do when you run make install or make build.
after that is run yarn run-demo and my project has been up! 🐟

"gatsby-plugin-sharp" plugin Couldn't be found when gatsby develop command is ran

Got a new pc and cloned my project from GitHub, then run npm install but then it installed with lots of errors, so now I ran gatsby develop and got the error messages below. please assist me
ERROR #10226 CONFIG
Couldn't find the "gatsby-plugin-sharp" plugin declared in "C:\Users\Administrator\Desktop\Projects\IamJude\gatsby-config.js".
Tried looking for a local plugin in C:\Users\Administrator\Desktop\Projects\IamJude\plugins\gatsby-plugin-sharp.
Tried looking for an installed package in the following paths:
C:\Users\Administrator\Desktop\Projects\IamJude\node_modules\gatsby\dist\bootstrap\load-themes\node_modules\gatsby-plugin-sharp
C:\Users\Administrator\Desktop\Projects\IamJude\node_modules\gatsby\dist\bootstrap\node_modules\gatsby-plugin-sharp
C:\Users\Administrator\Desktop\Projects\IamJude\node_modules\gatsby\dist\node_modules\gatsby-plugin-sharp
C:\Users\Administrator\Desktop\Projects\IamJude\node_modules\gatsby\node_modules\gatsby-plugin-sharp
C:\Users\Administrator\Desktop\Projects\IamJude\node_modules\gatsby-plugin-sharp
C:\Users\Administrator\Desktop\Projects\node_modules\gatsby-plugin-sharp
C:\Users\Administrator\Desktop\node_modules\gatsby-plugin-sharp
C:\Users\Administrator\node_modules\gatsby-plugin-sharp
C:\Users\node_modules\gatsby-plugin-sharp
C:\node_modules\gatsby-plugin-sharp
not finished open and validate gatsby-configs - 1.329s
ERROR
The above error occurred in the component:
in CLI (created by ConnectedCLI)
in ConnectedCLI
in StoreStateProvider
in App
React will try to recreate this component tree from scratch using the error boundary you provided, App.
ERROR
Warning: App: Error boundaries should implement getDerivedStateFromError(). In that method, return a state update to display an error message or fallback UI.
C:\Users\Administrator\AppData\Roaming\npm\node_modules\gatsby-cli\node_modules\yoga-layout-prebuilt\yoga-layout\build\Release\nbind.js:53
throw ex;
^
TypeError: Cannot read property 'activities' of undefined
at getGlobalStatus (C:\Users\Administrator\AppData\Roaming\npm\node_modules\gatsby-cli\lib\reporter\redux\utils.js:25:54)
at createPendingActivity (C:\Users\Administrator\AppData\Roaming\npm\node_modules\gatsby-cli\lib\reporter\redux\internal-actions.js:114:51)
at C:\Users\Administrator\AppData\Roaming\npm\node_modules\gatsby-cli\node_modules\redux\lib\redux.js:483:35
at prematureEnd (C:\Users\Administrator\AppData\Roaming\npm\node_modules\gatsby-cli\lib\reporter\catch-exit-signals.js:39:38)
at Reporter.panic (C:\Users\Administrator\AppData\Roaming\npm\node_modules\gatsby-cli\lib\reporter\reporter.js:72:42)
at process. (C:\Users\Administrator\AppData\Roaming\npm\node_modules\gatsby-cli\lib\index.js:79:21)
at process.emit (events.js:327:22)
at processEmit (C:\Users\Administrator\AppData\Roaming\npm\node_modules\gatsby-cli\node_modules\signal-exit\index.js:161:32)
at process.emit (C:\Users\Administrator\AppData\Roaming\npm\node_modules\gatsby-cli\node_modules#turist\fetch\dist\sourcemap-register.js:926:21)
at processEmit [as emit] (C:\Users\Administrator\Desktop\Projects\IamJude\node_modules\gatsby\node_modules\gatsby-cli\node_modules\signal-exit\index.js:161:32)
at processPromiseRejections (internal/process/promises.js:209:33)
at processTicksAndRejections (internal/process/task_queues.js:98:32)
What is the contents of your package.json?
Do you having gatsby-plugin-sharp installed?
Maybe try npm install --save gatsby-plugin-sharp
In Windows, you may need to make add a few extra packages to make the project run. First of all, I will try to add manually the gatsby-plugin-sharp by:
npm install --save gatsby-plugin-sharp
If the error persists, you may need to add windows-build-tools as you can see in the Gatsby on Windows documentation:
npm install --global windows-build-tools --vs2015
The command above, upon installing this package, it downloads and installs Visual C++ Build Tools 2015, provided free of charge by Microsoft. These tools are required to compile popular native modules. It will also install Python 2.7, configuring your machine and npm appropriately.
If your windows-build-tools installation stalls after Visual Studio Build Tools finishes, this remedy might help.

ReactNative: Trying to debbug cannot find module

I'm trying to debug my app. In the past everything worked perfectly. Then I formatted the computer, downloaded the project I had saved from git.
At this point, every time I try to run npm start in the terminal or to use the react native tool of visual studio code to debug the app or in any case to update the app connected to my device I get this error:
Error: Cannot find module '/Users/..../node_modules/#react-native-community/cli/build/index.js'. Please verify that the package.json has a valid "main" entry
at tryPackage (internal/modules/cjs/loader.js:338:19)
at Function.Module._findPath (internal/modules/cjs/loader.js:719:18)
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1072:27)
at Function.Module._load (internal/modules/cjs/loader.js:928:27)
at Module.require (internal/modules/cjs/loader.js:1145:19)
at require (internal/modules/cjs/helpers.js:75:18)
at Object.<anonymous> (/Users/.../node_modules/react-native/cli.js:12:11)
at Module._compile (internal/modules/cjs/loader.js:1256:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1277:10)
at Module.load (internal/modules/cjs/loader.js:1105:32) {
code: 'MODULE_NOT_FOUND',
path: '/Users/..../node_modules/#react-native-community/cli/package.json',
requestPath: '#react-native-community/cli'
I don't understand how can I do.
I remember that before when I made a change to the code I just needed to run npm start to reload my project and see the changes in my device. Now I absolutely can't get the code and device to interact.
How can I do?
You try reinstall React LI:
npm install –g react-native-cli
and install dependences:
npm install

Error when starting basic react app created with Create-react-app

I am new to react and am trying to start a basic react webapp following this "Getting Started" tutorial.
npx create-react-app first_react_app
cd first_react_app
npm start
Unfortunately I am getting the following error when starting the app.
C:\Users\user\Desktop\Lernprojekte\React\first_react_app\node_modules\react-dev-utils\WebpackDevServerUtils.js:166
compiler.hooks.done.tap('done', async stats => {
^^^^^
SyntaxError: missing ) after argument list
at Object.exports.runInThisContext (vm.js:78:16)
at Module._compile (module.js:543:28)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (C:\Users\user\Desktop\Lernprojekte\React\first_react_app\node_modules\react-scripts\scripts\start.js:45:5)
at Module._compile (module.js:571:32)
I read that async/await is not compatible with some lower versions of node.
I am using node 9.8.0 and npm 6.9.0 in windows 10.
I even deleted the node_modules and npm install again but still getting the same error.
As mentioned in this docs: Try this
npm run build
then
npm run start
If you follow react tutorials(react basic tutorial), you should see quick start commands and try to run these commands.
npx create-react-app first_react_app
cd first_react_app
npm start
and make sure your system has preinstalled npm to start with react.
Or you need to update your dev server file to remove this syntax error.
go to file in your project React\first_react_app\node_modules\react-dev-utils\WebpackDevServerUtils.js
go to line no 145 and Update given code.Save this file and restart your server.
compiler.hooks.done.tap('done', stats => {
if (isInteractive) {
clearConsole();
}
i came across the same problem, and although i upgraded npm & node to the latest versions, they were NOT the most updated in the directory of the react-app that I created.
solution: go to the directory of your react-app and upgrade npm & node
nvm install --latest-npm
Looks like your node.js version is outdated. You can update to the latest one or you can configure multiple node.js versions simultaneously. I am using 'n' a node version manager, so, that I can switch back and forth easily for managing multiple projects. You can read about this in the following link:
n
You can install it like this:
> npm install -g n #install utility globally
> n 10.16.0 #install the version you want
> n #switch back and forth to node.js versions
To know more about the node.js LTS version visit here:
node-release

Not able to create new app using the "create-react-native-app"

I have never encountered any issue in all my time creating react-native apps using the "create-react-native-app" cli command until today. It didn't create the usual ios and android file it creates but instead only create the node_modules, package-lock.json and package.json files. Below is the output i got back when i ran the command.
$ create-react-native-app Rdx
Creating a new React Native app in /Users/apple/Documents/Vscode/Redux-Testing/Rdx.
Using package manager as npm with npm interface.
Installing packages. This might take a couple minutes.
Installing react-native-scripts...
npm notice created a lockfile as package-lock.json. You should commit this file.
+ react-native-scripts#2.0.1
added 20 packages in 19.223s
(node:73947) UnhandledPromiseRejectionWarning: Error: Cannot find module '/Users/apple/Documents/Vscode/Redux-Testing/Rdx/node_modules/react-native-scripts/build/scripts/init.js'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at _callee2$ (/Users/apple/npm/lib/node_modules/create-react-native-app/build/index.js:128:32)
at tryCatch (/Users/apple/npm/lib/node_modules/create-react-native-app/node_modules/regenerator-runtime/runtime.js:62:40)
at Generator.invoke [as _invoke] (/Users/apple/npm/lib/node_modules/create-react-native-app/node_modules/regenerator-runtime/runtime.js:296:22)
at Generator.prototype.(anonymous function) [as next] (/Users/apple/npm/lib/node_modules/create-react-native-app/node_modules/regenerator-runtime/runtime.js:114:21)
at step (/Users/apple/npm/lib/node_modules/create-react-native-app/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)
at /Users/apple/npm/lib/node_modules/create-react-native-app/node_modules/babel-runtime/helpers/asyncToGenerator.js:28:13
(node:73947) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:73947) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Thank you in advance for all your support!
Its because react-native-scripts package is old which is used by create-react-native-app may be now your version create-react-native-app will be version: 1.0.0.
update the package.
npm install -g create-react-native-app
now create-react-native-app version will be 2.0.2.
You are now ready to create your app.
create-react-native-app Rdx
You may asked to install expo-cli say Y.
Another good thing in create-react-native-app 2.0.2 is you can create blank or tabs app. use arrow keys to select your preferred app in terminal.
The version of create-react-native-app that you are using is quite old. It uses react-native-scripts instead of Expo SDK.
You need to use the correct version of react-native-scripts. You can do this by specifying the correct react-native-script version when creating a new project with create-react-native-app. To find the correct version of react-native-scripts, first find out the version of create-react-native-app using the command:
create-react-native-app --version
Next see the Changelogs for both create-react-native-app and react-native-scripts.
Choose a version of react-native-scripts that was released around same time as your version of create-react-native-apps.
After that specify the version of react-native-scripts when creating a new project with create-react-native-app. For example:
create-react-native-app --scripts-version 1.4.0 project-name

Resources