Module … has no default export

When a Node.js module import causes the

Module … has no default export
or
Internal server error: [vite] The requested module ‘…’ does not provide an export named ‘default’

error message, change the import statement, update the function name, and enclose the function name with curly braces:

# Replace
import jwt_decode from "jwt-decode";
# with
import { jwtDecode } from "jwt-decode"; 

This table contains the old and new function names

Old function nameNew function name
jwt_decodejwtDecode

Leave a comment

Your email address will not be published. Required fields are marked *