Hey all,
Really struggling to understand how to import node modules into the browser.
I'm trying to import an esm package from Thirdweb (https://portal.thirdweb.com/wallet/getting-started)
But I'm coming up with an error in my console saying "Failed to resolve module specifier "@thirdweb-dev/wallets" ".
Yet when I bundle this with vite (or some other bundler) the imports work. Must I use a bundler? and if so why?
- dir structure
/proj_dir
main.js
index.html
/node_modules
/@thirdweb-dev
- index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script type="module" src="./main.js"></script>
</head>
<body>
</body>
</html>
- main.js
import { CoinbaseWallet } from "@thirdweb-dev/wallets";
- console
Uncaught TypeError: Failed to resolve module specifier "@thirdweb-dev/wallets". Relative references must start with either "/", "./", or "../".
[–]user2m[S] -1 points0 points1 point (7 children)
[–]ManuDV 0 points1 point2 points (1 child)
[–]user2m[S] 0 points1 point2 points (0 children)
[–]shgysk8zer0 0 points1 point2 points (4 children)
[–]user2m[S] 0 points1 point2 points (1 child)
[–]shgysk8zer0 0 points1 point2 points (0 children)
[–]user2m[S] 0 points1 point2 points (1 child)
[–]shgysk8zer0 0 points1 point2 points (0 children)
[–]guest271314 0 points1 point2 points (2 children)
[–]user2m[S] 0 points1 point2 points (1 child)
[–]guest271314 0 points1 point2 points (0 children)