Skip to content

Build Fails with @hashgraph/sdk and hashconnect in Next.js TypeScript Project #212

@PuneethReddyHC

Description

@PuneethReddyHC

I'm encountering an issue when trying to connect to the HashPack wallet using the following package versions in my Next.js TypeScript project:

@hashgraph/sdk: 2.45.0
hashconnect: ^3.0.13
The connection works correctly when running the development server with npm run dev, but the build process fails. Below is the error message I receive:

of Uint8Array){var s=0,l=t.length,c=t.charAt(0),u=[0];for(s=0;s<e.length;++s){for(var d=0,p=e[s];d<u.length;++d)p+=u[d]<<8,u[d]=p%l,p=p/l|0;for(;p>0;)u.push(p%l),p=p/l|0}for(s=0;0===e[s]&&s<e.length-1;++s)i+=c;for(s=u.length-1;s>=0;--s)i+=t[u[s]]}else i=a(e,t);if(o){var h=RegExp(".{1,"+o+"}","g");i=i.match(h).join(`\r

SyntaxError: Identifier 'r' has already been declared
    at internalCompileFunction (node:internal/vm:73:18)
    at wrapSafe (node:internal/modules/cjs/loader:1178:20)
    at Module._compile (node:internal/modules/cjs/loader:1220:27)    
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Module.load (node:internal/modules/cjs/loader:1119:32)        
    at Module._load (node:internal/modules/cjs/loader:960:12)        
    at Module.require (node:internal/modules/cjs/loader:1143:19)     
    at mod.require (C:\Users\PuneethReddy\Documents\Frontend\my-next-app\node_modules\next\dist\server\require-hook.js:65:28)
    at require (node:internal/modules/cjs/helpers:119:18)
    at requirePage (C:\Users\PuneethReddy\Documents\Frontend\my-next-app\node_modules\next\dist\server\require.js:109:84)

> Build error occurred
Error: Failed to collect page data for /
    at C:\Users\PuneethReddy\Documents\Frontend\my-next-app\node_modules\next\dist\build\utils.js:1268:15
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  type: 'Error'
}

I've also tried using older versions of @hashgraph/sdk and hashconnect:

@hashgraph/sdk: 2.41.0
hashconnect: ^3.0.12
But the issue persists.

Steps to Reproduce:

Set up a Next.js TypeScript project.
Install @hashgraph/sdk and hashconnect using the specified versions.
Attempt to connect to the HashPack wallet.
Run npm run dev to see that the connection works in development mode.
Run npm run build to reproduce the build error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions