Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module not found: Can't resolve 'encoding' in '/Users/anthonyalbertorio/Desktop/audius-nft/audius-nft/node_modules/@audius/fetch-nft/dist' #25

Open
tesla809 opened this issue Oct 24, 2023 · 0 comments

Comments

@tesla809
Copy link

tesla809 commented Oct 24, 2023

Describe the bug

According to error message: Can't resolve 'encoding' for npm package.

To Reproduce

see below code:

// USING NEXTJS@13
// ./src/app/page.tsx

import React, { useEffect, useState } from "react";
import Image from "next/image";

import { FetchNFTClient } from "@audius/fetch-nft";

import NFT from "./NFT";

// FETCH - TESTING OUT FETCH API
async function getPuppers() {
  const response = await fetch("https://dog.ceo/api/breeds/image/random", {
    cache: "no-cache",
  });
  const data = await response.json();
  return data;
}

// NFT
// upon checking Opensea the address: GrWNH9qfwrvoCEoTm65hmnSh4z3CD96SfhtfQY6ZKUfY
// doesn't yield anything.
// Where is this data being pulled from?
// GETTING ISSUES WITH API
async function getSolanaCollectibles() {
  // Initialize fetch client
  const fetchClient = new FetchNFTClient();

  // Fetching Solana collectibles for the given wallets
  return fetchClient
    .getSolanaCollectibles(["GrWNH9qfwrvoCEoTm65hmnSh4z3CD96SfhtfQY6ZKUfY"])
    .then(({ res }) => {
      return res;
    });
}

// TESTING OUT OPENSEA API since Fetch-API is causing issues for setup
async function getEthereumCollectibles() {
  const sdk = require("api")("@opensea/v2.0#1nqh2zlnvr1o4h");
  sdk.auth("04c8ae776ac44b4cabebbed161dfbc8c");
  sdk.server("https://api.opensea.io");
  return await sdk
    .list_nfts_by_account({
      chain: "ethereum",
      address: "0x5A8443f456f490dceeAD0922B0Cc89AFd598cec9",
    })
    .then(({ data }) => {
      return data;
    })
    .catch((err) => console.error(err));
}

export default async function Home() {
  const dogs = await getPuppers();
  console.log(dogs);

  let ethAssets;
  const getEthData = await getEthereumCollectibles().then((res) => {
    ethAssets = res; // get base object
    console.log("WORKING DATA:", ethAssets);
    console.log("DATA 1:", ethAssets.nfts[0]);
  });

  let solAssets;
  const getSolData = await getSolanaCollectibles().then((res) => {
    solAssets = res; // get base object
    console.log("WORKING DATA:", solAssets);
  });

  return (
    <div>
      <h1>Audius Data</h1>
      <NFT data={ethAssets.nfts} />

      <h1>Doggos Data</h1>
      <Image
        src={dogs.message}
        width={500}
        height={500}
        alt="doggos"
        priority
      />
    </div>
  );
}

Supporting Media

⚠ ./node_modules/@audius/fetch-nft/dist/index.js
Module not found: Can't resolve 'encoding' in '/Users/anthonyalbertorio/Desktop/audius-nft/audius-nft/node_modules/@audius/fetch-nft/dist'

Import trace for requested module:
./node_modules/@audius/fetch-nft/dist/index.js
./src/app/page.tsx

./node_modules/node-fetch/lib/index.js
Module not found: Can't resolve 'encoding' in '/Users/anthonyalbertorio/Desktop/audius-nft/audius-nft/node_modules/node-fetch/lib'

Import trace for requested module:
./node_modules/node-fetch/lib/index.js
./node_modules/@solana/web3.js/lib/index.cjs.js
./node_modules/@audius/fetch-nft/dist/index.js
./src/app/page.tsx
 ⚠ ./node_modules/@audius/fetch-nft/dist/index.js
Module not found: Can't resolve 'encoding' in '/Users/anthonyalbertorio/Desktop/audius-nft/audius-nft/node_modules/@audius/fetch-nft/dist'

Import trace for requested module:
./node_modules/@audius/fetch-nft/dist/index.js
./src/app/page.tsx

./node_modules/node-fetch/lib/index.js
Module not found: Can't resolve 'encoding' in '/Users/anthonyalbertorio/Desktop/audius-nft/audius-nft/node_modules/node-fetch/lib'

Import trace for requested module:
./node_modules/node-fetch/lib/index.js
./node_modules/isomorphic-fetch/fetch-npm-node.js
./node_modules/api/dist/cache.js
./node_modules/api/dist/index.js
./src/app/page.tsx
                         

Expected behavior

Expected to see Solana data upon running npm run dev.

Your environment

Dev Environment

{
  "name": "audius-nft",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint"
  },
  "dependencies": {
    "@audius/fetch-nft": "^0.1.8",
    "@solana/spl-token": "^0.1.8",
    "@solana/web3.js": "^1.87.2",
    "module-alias": "^2.2.3",
    "next": "13.5.6",
    "react": "^18",
    "react-dom": "^18"
  },
  "devDependencies": {
    "@types/node": "^20",
    "@types/react": "^18",
    "@types/react-dom": "^18",
    "autoprefixer": "^10",
    "eslint": "^8",
    "eslint-config-next": "13.5.6",
    "postcss": "^8",
    "tailwindcss": "^3",
    "typescript": "^5"
  }
}

OS

OS: MacOS 13.4 - Ventura
NextJS: 13
Node version: V20.5.0
Npm version: 9.8.1
Browser name and version: Chrome 118.0.5993.70

Additional context:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant