Closed META-DREAMER closed 2 years ago
It's likely an issue with Create React App, it's using an outdated version of Webpack. You should use Webpack 5 or an alternative modern bundler.
I seem to be getting a similarish error with Next.js when I import usePublicRecord
from @self.id/framework
I installed @3id/connect@^0.2.5
separately and confirmed that EthereumAuthProvider
does exist - just looks like for some reason it's not being found by @self.id/web
(see call stack at the end)
Any ideas?
Server Error
SyntaxError: Named export 'EthereumAuthProvider' not found. The requested module '@3id/connect' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:
import pkg from '@3id/connect';
const {ThreeIdConnect: l}from"@3id/connect";import{EthereumAuthProvider: k}from"@3id/connect";import{Core: v}from"@self.id/core";import{DID: f}from"dids";var s=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},d=(t,e,r)=>(s(t,e,"read from private field"),r?r.call(t):e.get(t)),w=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},p=(t,e,r,a)=>(s(t,e,"write to private field"),a?a.call(t,r):e.set(t,r),r),n;class o extends v{constructor(e){super(e);w(this,n,void 0),p(this,n,new l(e.connectNetwork??e.ceramic))}get threeId(){return d(this,n)}async authenticate(e,r=!0){const a=await this.connect(e);return await a.authenticate(),r&&(this.ceramic.did=a),a}async connect(e){return await d(this,n).connect(e),new f({provider:d(this,n).getDidProvider(),resolver:this.resolver})}}n=new WeakMap;var h=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},c=(t,e,r)=>(h(t,e,"read from private field"),r?r.call(t):e.get(t)),_=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},D=(t,e,r,a)=>(h(t,e,"write to private field"),a?a.call(t,r):e.set(t,r),r),i;const u=class{constructor(t){if(_(this,i,void 0),!t.client.ceramic.did?.authenticated)throw new Error("Input DID must be authenticated, use SelfID.authenticate() instead of new SelfID()");D(this,i,t.client)}static async authenticate(t){const{authProvider:e,...r}=t,a=new o(r);return await a.authenticate(e,!0),new u({client:a})}get client(){return c(this,i)}get did(){const t=c(this,i).ceramic.did;if(t==null||!t.authenticated)throw new Error("Expected authenticated DID instance to be attached to Ceramic");return t}get id(){return this.did.id}async get(t){return await c(this,i).dataStore.get(t,this.did.id)}async set(t,e){return await c(this,i).dataStore.set(t,e)}async merge(t,e){return await c(this,i).dataStore.merge(t,e)}};let I=u;i=new WeakMap;export{k: EthereumAuthProvider,I: SelfID,o: WebClient} = pkg;
Call Stack
<unknown>
file:///Users/jon/code/ccl/commentor/node_modules/@self.id/web/dist/lib.mjs (1)
ModuleJob._instantiate
node:internal/modules/esm/module_job (124:21)
async ModuleJob.run
node:internal/modules/esm/module_job (181:5)
async ESMLoader.import
node:internal/modules/esm/loader (281:24)
async importModuleDynamicallyWrapper
node:internal/vm/module (437:15)
@META-DREAMER idk if this was your issue but I fixed it with a tweak to my Next.js config https://github.com/vercel/next.js/issues/30750 :)
Getting this error when trying to use
@self.id/core
:Running with create-react-app + typescript, node 14.7