Could not resolve package that is imported in node_module dependency in Nuxt 3 (apollo client) - import

I'v added Apollo client to Nuxt 3 (With Vite) project but on yarn dev it fails and throws
✘ [ERROR] Could not resolve "react"
node_modules/#apollo/client/react/hooks/useApolloClient.js:2:27:
2 │ import { useContext } from 'react';
╵ ~~~~~~~
You can mark the path "react" as external to exclude it from the bundle, which will remove this
error.
✘ [ERROR] Could not resolve "react"
node_modules/#apollo/client/react/hooks/useMutation.js:2:57:
2 │ import { useCallback, useEffect, useRef, useState } from 'react';
╵ ~~~~~~~
You can mark the path "react" as external to exclude it from the bundle, which will remove this
error.
Q: So how can I mark path "react" as external ? Or make it to work, couldn't find any tutorials how to do it.

The issue was in #apollo/client import,
make sure that all imports are from #apollo/client/core
Example
import {
ApolloClient,
ApolloLink,
HttpLink,
InMemoryCache,
PureQueryOptions
} from "#apollo/client/core";
[!]Not: .. from "#apollo/client";

Related

Flutter Location Import Errors

I am trying to use the Location plugin (https://pub.dev/packages/location#-readme-tab-)
I have included all dependencies in the analysis and tried to test using the example however, the following imports are throwing errors "Target of URI doesn't exist..."
import 'get_location.dart';
import 'listen_location.dart';
import 'permission_status.dart';
import 'service_enabled.dart';
I tried to import dependencies and changed my settings.gradle with no success. Any advice is greatly appreciated.

Cannot find symbol import com.facebook.CallbackManager

Currently working on a react app which uses the Facebook SDK. It seems to brake on the import of com.facebook.CallbackManager with the following error:
/android/app/src/main/java/com/phonebook/theredcorner/MainApplication.java:5: error: cannot find symbol import com.facebook.CallbackManager;
I've tried many suggestions online but it all doesn't seem to work. Anyone recently got this error and knows how to solve it?
I'm importing it in my MainApplication.java as follows
package com.phonebook.theredcorner;
import android.app.Application;
import com.facebook.CallbackManager;
import com.facebook.FacebookSdk;
import com.facebook.reactnative.androidsdk.FBSDKPackage;
import com.facebook.appevents.AppEventsLogger;
Furthermore I've followed all steps on the Facebook getting started page to implement the Facebook SDK.
The Facebook SDK was published as an independent module to Maven. Include the dependency in the app/build.gradle file.
dependencies {
// Facebook Core only (Analytics)
implementation 'com.facebook.android:facebook-core:5.0.0'
}
You may also need to add the following to your project/build.gradle file.
buildscript {
repositories {
mavenCentral()
}
}
If the error persists after installation, make sure the file is in the next path.
facebook-android-sdk/facebook-core/src/main/java/com/facebook/CallbackManager.java

module in material-ui not longer found

It's been running fine for several months now, but since I've re-installed the node_modules folder I got this error.
Module not found: Can't resolve 'final-form-material-ui/dist' in '....'
package.json
...
"dependencies": {
"#material-ui/core": "^3.9.3",
"#material-ui/icons": "^3.0.2",
...
In the component, i use:
import {TextField, Input} from 'final-form-material-ui/dist';
And in the node_modules/final-form-material-ui/dist folder I do have the TextField.d.ts and the Input.d.ts files.
Any clues?
You need to import the right package from #material-ui/core.
import {TextField, Input} from '#material-ui/core';
changed as suggested / asked / queried by HRK44
import {TextField, Input} from '#material-ui/core';

IONIC 3: Plugin BackgroundMode dont work: Object(…) is not a function

I need to run the code “this.backgroundMode.enable()” in my project, but it shows me the following error:
"Object(...) is not a function"
It imports it in app.module.ts in the following way:
import {BackgroundMode} from '# ionic-native / background-mode / ngx';
...
providers: [
...
BackgroundMode
...]
And in the page (in my case is in app.component.ts, after deviceready, like the official documentation says) i use like:
import {BackgroundMode} from '# ionic-native / background-mode / ngx';
constructor(private backgroundMode: BackgroundMode) { }
...
this.backgroundMode.enable();
Please I need to run this plugin in my project
I have answered a similar question here https://stackoverflow.com/a/54398403/6617276
Check your project type in ionic.config.json file.
If the type is "ionic-angular", then install 4.x.x version.
npm i -s #ionic-native/background-mode#4.20.0
If the type is "angular", then install 5.x.x-beta version
npm i -s #ionic-native/background-mode#5.0.0-beta.24
Note:
Add ngx at the end of import only if you are using Angular 6
import { BackgroundMode } from '#ionic-native/background-mode/ngx';
if not remove ngx from the import both in app.module.ts and app.component.ts
import { BackgroundMode } from '#ionic-native/background-mode';

Cannot find class in package when compiling with javac

I have the following structure in my directory :
PROJECT
- classes
tunnelvisionlabs
postgresql
PostgreSqlLexer.class
PostgreSqlLexerAtnSimulator.class
PostgreSqlLexerUtils.class
- lib
antlr-4-7.jar
- BasicTest.java
In BasicTest.java, i have these imports:
package com.tunnelvisionlabs.postgresql.test;
import com.tunnelvisionlabs.postgresql.PostgreSqlLexer;
import com.tunnelvisionlabs.postgresql.PostgreSqlLexerUtils;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import org.antlr.v4.runtime.ANTLRInputStream;
import org.antlr.v4.runtime.CommonTokenStream;
import org.antlr.v4.runtime.Lexer;
import org.antlr.v4.runtime.Token;
import org.junit.Assert;
import org.junit.Test;
I try to compile with the following command :
javac -cp .:./lib/* BasicTests.java
I get these errors :
BasicTests.java:28: error: cannot find symbol
import com.tunnelvisionlabs.postgresql.PostgreSqlLexer;
^
symbol: class PostgreSqlLexer
location: package com.tunnelvisionlabs.postgresql
BasicTests.java:29: error: cannot find symbol
import com.tunnelvisionlabs.postgresql.PostgreSqlLexerUtils;
^
symbol: class PostgreSqlLexerUtils
location: package com.tunnelvisionlabs.postgresql
In the PostgreSqlLexer and PostgreSqlLexerUtils classes, i have this package declared at the beginning:
package com.tunnelvisionlabs.postgresql;
What do i need to do for my program to find these classes ? I tried adding the classes directory in lib and using the same command as before, so that the classpath also contains the classes directory, but it doesn't change anything.
If I read your project structure correctly, the source folder where BasicTest.java sits is at the same level as the lib folder. If so, then you can using the following javac classpath:
javac -cp .:lib/* BasicTests.java
^^^ lib/ is already where you are calling this
Review the following reference answer for more information:
Including all the jars in a directory within the Java classpath