If you're using Vite.js with react and using the Dynamic SDK with Starknet, you may get a similar error to this one in your console:
Uncaught SyntaxError: The requested module '/[APP_PATH]/node_modules/.vite/deps/starknet.js?v=5327d40a' does not provide an export named 'default'This is because older versions of Vite don't know how to resolve the starknet module exports.
Resolution
Add resolve alias for starknet using vite.config.js
To fix this, modify the vite.config.js file to add an alias for starknet. Here is a minimal config example:
TypeScript
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import * as path from 'path';
export default defineConfig({
plugins: [react()],
resolve: {
alias: {
'starknet': path.resolve(__dirname, 'node_modules/starknet/dist/index.mjs')
}
}
})