Failed to resolve entry for package "appwrite". The package may have incorrect main/module/exports specified in its package.json. error

108 views Asked by At

Was working on the react app and used appwrite as my backend but it is giving me the following error;

** Failed to resolve entry for package "appwrite". The package may have incorrect main/module/exports specified in its package.json.**

enter image description here

All I have done in the file which referred by the error (auth.js) is used some appwrite function for creating authorization. Here is the code below for that file,

\`import conf from './config';
import { Client, Account, ID } from "appwrite";

export class AuthService {

    client = new Client();
    Account;
    
    constructor() {
        this.client
            .setEndpoint(conf.appwriteURL)
            .setProject(conf.projectID);
    
        this.Account = new Account(this.client)
    }
    
    async createAccount({ email, password, name }) {
        try {
    
            const userAccount = await this.Account.create(ID.unique(), email, password, name);
    
            if (userAccount) {
                // call other methd
                return this.login(email, password);
            }
            else {
                return userAccount;
            }
        } catch (error) {
            console.log(`Appwrite error: createAccount() :: ${error}`)
    
        }
    }
    
    async login(email, password) {
        try {
            return await Account.createEmailSesson(email, password);
        } catch (error) {
            console.log(`Appwrite error: login() :: ${error}`)
    
        }
    }
    
    async getCurrentUser() {
        try {
    
            return this.Account.get();
    
        } catch (error) {
            console.log(`Appwrite error: getCurrentUser() :: ${error}`)
        }
    
        return null;
    }
    
    async logOut(){
        try {
    
            return this.Account.deleteSessions();
    
        } catch (error) {
            console.log(`appwrite :: logOut() : ${error}`)
        }
    }

}

const authService = new AuthService();

export default authService;\

Though I have provided all the code related to the file the error referring to, I don't really think the problem is more about the code. I think there is some problem in installing or importing the appwrite.

0

There are 0 answers