I found this library wemo-client that recognize Wemo devices so i can use them in the application , i installed it with yarn add wemo-client , but when i use the snippets in my home component and i start the application it gives me this error:
error: Error: While trying to resolve module http from file /Users/user/lavoro/appname/node_modules/wemo-client/index.js, the package /Users/user/lavoro/appname/node_modules/http/package.json was successfully found. However, this package itself specifies a main module field that could not be resolved (/Users/gretacalamari/lavoro/appname/node_modules/http/index. Indeed, none of these files exist:
/Users/user/lavoro/appname/node_modules/http/index(.native|.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)
/Users/user/lavoro/appname/node_modules/http/index/index(.native|.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)
at DependencyGraph.resolveDependency (/Users/user/lavoro/appname/node_modules/metro/src/node-haste/DependencyGraph.js:376:17)
at Object.resolve (/Users/user/lavoro/appname/node_modules/metro/src/lib/transformHelpers.js:271:42)
at resolve (/Users/user/lavoro/appname/node_modules/metro/src/DeltaBundler/traverseDependencies.js:571:33)
at /Users/user/lavoro/appname/node_modules/metro/src/DeltaBundler/traverseDependencies.js:587:26
at Array.reduce ()
at resolveDependencies (/Users/user/lavoro/appname/node_modules/metro/src/DeltaBundler/traverseDependencies.js:586:33)
at /Users/user/lavoro/appname/node_modules/metro/src/DeltaBundler/traverseDependencies.js:275:33
at Generator.next ()
at asyncGeneratorStep (/Users/user/lavoro/appname/node_modules/metro/src/DeltaBundler/traverseDependencies.js:87:24)
at _next (/Users/user/lavoro/appname/node_modules/metro/src/DeltaBundler/traverseDependencies.js:107:9)
i tried to remove node modules then yarn , update and downgrade http and url but none of these steps work.
can you help me , if you need if i will give them to you very greatfully
New to React Native:
I started a brand new project with Expo init and then I followed the instructions mentioned inhttps://reactnavigation.org/docs/hello-react-navigation
I run the project with expo start and I get this error.
Invariant Violation: "main" has not been registered. This can happen if:
Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
A module failed to load due to an error and AppRegistry.registerComponent wasn't called.
invariant
browser.js:38:14
runApplication
AppRegistry.js:193:13
__callFunction
MessageQueue.js:425:19
__guard$argument_0
MessageQueue.js:112:6
__guard
MessageQueue.js:373:10
callFunctionReturnFlushedQueue
MessageQueue.js:111:4
callFunctionReturnFlushedQueue
[native code]:0
Any suggestions?
Open the index.js, the content of the file should be like this:
import { AppRegistry, Platform } from 'react-native';
import App from './App';
AppRegistry.registerComponent('X', () => App);
if (Platform.OS === 'web') {
const rootTag = document.getElementById('root') || document.getElementById('X');
AppRegistry.runApplication('X', { rootTag });
}
If you have this error Invariant Violation: “main” has not been registered you have to replace the 'X' by 'main'.
Another example :
If you have this error Invariant Violation: “app” has not been registered you have to replace the 'X' by 'app'.
For android :
Open ./android/app/src/main/java/[multiple folders]/MainActivity.java
/**
* Returns the name of the main component registered from JavaScript.
* This is used to schedule rendering of the component.
*/
#Override
protected String getMainComponentName() {
return "X";
}
The 'X' of MainActivity.java and index.js must match.
This worked for me:
delete node_modules and your lockfile (package-lock.json / yarn.lock)
change the expo package version in package.json to 38.0.8
run yarn or npm install
run expo install react-native-safe-area-context
The problem is that if you are using expo then you have to registerComponent differently. All the information is in the docs. https://docs.expo.io/versions/latest/sdk/register-root-component/
import { registerRootComponent } from 'expo';
import React from 'react';
import { View } from 'react-native';
class App extends React.Component {
render() {
return <View />;
}
}
registerRootComponent(App);
In my case, the problem was solved when I called
AppRegistry.registerComponent(appName.toLowerCase(), () => App);
in index.js. So it looks like the first parameter is to be passed based on what error message is shown. In my case, my project name was AwesomeProject and the error reported by Metro was:
Invariant Violation: "awesomeproject" has not been registered.
so I figured that adding toLowerCase() will solve the problem and it did!!
However, I was facing this problem when trying to run it on macos using npx react-native run-macos and after this was solved, I tried to invoke the iOS version, then I got Invariant Violation: "AwesomeProject" has not been registered.
So finally I got both working by registering the App twice as below:
AppRegistry.registerComponent(appName, () => App);
AppRegistry.registerComponent(appName.toLowerCase(), () => App);
The same also works with npx react-native run-android.
workarounded by:
AppRegistry.registerComponent('main', () => App);
In my case I was missing some packages which are mandatory to install.
npm install react-native-reanimated react-native-gesture-handler react-native-screens react-native-safe-area-context #react-native-community/masked-view
index.js
AppRegistry.registerComponent("X", () => Root);
If you are facing this issue in Android then make sure that both mainactivity.java and index.js contains same "X"
mainActivity.java
#Override
protected String getMainComponentName() {
return "X";
}
If you are facing this issue in iOS then make sure that both AppDelegate.m and index.js contains same "X"
AppDelegate.m
RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge moduleName:#"X" initialProperties:nil];
Change your index.js .
import { AppRegistry, Platform } from "react-native";
import { registerRootComponent } from "expo";
import App from "./App";
import { name as appName } from "./app.json";
// registerRootComponent calls AppRegistry.registerComponent('main', () => App);
// It also ensures that whether you load the app in the Expo client or in a native build,
// the environment is set up appropriately
if (Platform.OS == "android") {
registerRootComponent(App);
} else {
AppRegistry.registerComponent(appName, () => App);
}
In my case, I had a class that existed solely to model the structure of a meal i.e not a react class component. I forgot to export that class but was calling it in the application new Meal(foo, bar .....) and that triggered this error. I found it by just tracing my steps to the most recent addition I had made before I started getting this error.
In my case it a specific package called graphql-type-json that was the problem.
So the 2nd part of the error was referring to the real issue:
A module failed to load due to an error and AppRegistry.registerComponent wasn't called."'
The loading of the incriminated package was throwing an error 'GraphQLError: Syntax Error: Expected Name, found "}".' which stopped the App loading and threw the Invariant Violation error.
After removing precisely the graphql-type-json (yarn remove graphql-type-json) package, expo loaded fine again.
If you're using react-native-reanimated and Expo, make sure to install it using:
expo install react-native-reanimated
See the documentation for further help
import app name from app.json like this:
import {name as appName} from './app.json';
then add appname in registerComponent
AppRegistry.registerComponent(appName, () => App);
The main reason to get this error is that, for some reason, App.js is not functioning properly. It may be because that you are running the server from a wrong folder. In my case, I always got another error along with this error, so I kept fixing those and this error got resolved automatically.
It can happen after you've used expo prebuild --clean and when in your Podfile/AppDelegate.m was some 3rd party library specific import, like react-native-maps, or Google Maps API Key.
You'd need to put back these imports into Podfile/AppDelegate.m, next cd ios, next pod install. Still, expo start might be not enough and you'd need to build your project using Xcode. After building & running your code on Xcode, the error will be gone and the emulator will start.
There is some difference between how Expo and Xcode build/simulate the app, but I'm at quite an early stage regarding distinguishing these differences. I've also noticed sometimes you need to first build the project on Xcode first, if the app isn't installed on the simulator yet, and only then running the app from simulator launched via expo start --dev-client. Otherwise, I was getting an error Error: The development client (com.XYZ.ABC) for this project is not installed. Please build and install the client on the simulator first. or Invariant Violation: Native module cannot be null. or Invatian Violation: 'main' has not been registered....
If you have changed the application and package name using react-native-rename,
in the file ios/AppName/AppDelegate.mm
Synchronize the application name with the app.json file by finding the lineUIView *rootView = RCTAppSetupDefaultRootView(bridge, #"AppName", nil);
I'm not great at diagnosing these stack traces but my project just suddenly started throwing this error. I installed react-native-skeleton-content which then threw errors for react-native-gesture-handler here I am thinking that gesture handler was just a result of some other peer dependency updating.
I uninstalled both and voila. The expo server runs again and processes the app just fine. Had I slept on it I never would have known but yeah, as a newbie, try deleting a new package you just installed and it's dependencies. It's likely the cause of a new issue.
I finally found a solution that worked for me!
I just execute it again:
npm install -g expo-cli
ps.: In my case, it may have happened because I tried to install Turtle CLI and had to remove it to free disk space. This may have corrupted the expo files.
For iOS, we need to make one additional change in ios>appName>AppDelegate.mm file,
Search for RCTAppSetupDefaultRootView and update old_app_name to new_app_name
I am facing an issue while deploying React app on Vercel (same happens on Netlify). The problem is the application is working well locally but, when I try to deploy it, it fails to resolve the context that I have implemented. The following image shows the error:
Import statements at App.js
The project created using Vite.
[enter image description here][1]
import { UserProvider } from './contexts/user/UserContext';
import { LoadingProvider } from './contexts/loading/LoadingContext';
ERROR on Vercel:
Could not resolve './contexts/user/UserContext' from src/App.jsx
error during build:
Error: Could not resolve './contexts/user/UserContext' from src/App.jsx
at error (/vercel/path0/node_modules/rollup/dist/shared/rollup.js:198:30)
at ModuleLoader.handleResolveId (/vercel/path0/node_modules/rollup/dist/shared/rollup.js:22508:24)
at /vercel/path0/node_modules/rollup/dist/shared/rollup.js:22471:26
Error: Command "npm run build" exited with 1
The error message contexts/user/UserContext shows that it's expecting to find
contexts/user/UserContext
in
/vercel/path0/node_modules/rollup/dist/shared
I suspect you may not have a subfolder called contexts at that location at build time in the build environment.
Check your use of the relative path in your imports. You will need to ensure the folder ends up in the right place at build time, and that the import path resolves correctly in the build environment.
I am trying to install my app on my android device with "react-native run-android", but after installing "react-native-gesture-handler" I got an error "FAILURE: Build failed with an exception" and got 15 errors in "RNGestureHandlerModule.java" in the node_modules folder.
I tried many times to link gesture handler. But nothing change appears in the errors.
/projects/gitlabstyleseject/kono-app-styles/node_modules/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootViewManager.java:4: error: package com.facebook.react.module.annotations does not exist
import com.facebook.react.module.annotations.ReactModule;
^
/projects/gitlabstyleseject/kono-app-styles/node_modules/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootViewManager.java:17: error: cannot find symbol
#ReactModule(name = RNGestureHandlerRootViewManager.REACT_CLASS)
^
symbol: class ReactModule
/projects/gitlabstyleseject/kono-app-styles/node_modules/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.java:16:
error: package com.facebook.react.module.annotations does not exist
import com.facebook.react.module.annotations.ReactModule;
^
Task :react-native-gesture-handler:compileDebugJavaWithJavac FAILED
uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
15 errors
Please, suggest me how to solve these errors. And I am new to react native.
I installed ng-select2 package. And I'm getting this error and code is not able to complie after 'ng serve'.
node version is 8.10.0
npm version 6.0.0
List item
OS Windows 7
ERROR in d:/PATH-TO-PROJECT-FOLDER/node_modules/#types/select2/index.d.ts (233,49): 'JQuery' only refers to a type, but is being used as a namespace here.
ERROR in D:/PATH-TO-PROJECT-FOLDER/node_modules/ng-select2/ng-select2/ng-select2.component.ts (188,18): Cannot find name 'Select2Options'.
ERROR in /src/app/pages/dashboard/dashboard.component.ts (91,19): Cannot find name 'Select2Options'.
// Dashboard component ts(91, 19) error + I've also added import to it:
public options: Select2Options;
Solutions I tried are:
As per documentation, added import and also imported in #NgModule to app.module.ts
I've jquery#3.2.1 and #types/jquery#2.0.41 installed as well.
npm cache verify, then npm cache clean --force and updated npm
deleted package-lock.json and then ran npm install
But this doesn't seem to work.
As stated in the github issue:
The interface Select2Options is removed/renamed to Options in the latest version 4.0.45
To resolve this issue, I simply downgrade the package to 4.0.44 by running
npm install # types/select2#4.0.44 --save and this worked for me.
https://github.com/NejcZdovc/ng2-select2/issues/124
I had a similar problem. I installed according to the selected2 documentation. Unfortunately, an error appeared
Error: src/app/app.module.ts:6:33 - error TS2307: Cannot find module './select2' or its corresponding type declarations.
6 import { NgSelect2Module } from './select2';
Although it was in the Initial Chunk Files
Initial Chunk Files | Names
select2.js | select2
I tried your solution but the compiler said it is not a module.
Error: src/app/app.module.ts:6:33 - error TS2306: File 'C:/Users/admin/Documents/WorkspaceAngular/medical-v0.9/node_modules/#types/select2/index.d.ts' is not a module.
6 import { NgSelect2Module } from '#types/select2',
So I installed componenet
npm i ng-select2-component --save
https://www.npmjs.com/package/ng-select2-component
It worked ;-)