If I just run npm install web3 I get a bunch of errors
Module not found: Error: Can't resolve 'stream'
Module not found: Error: Can't resolve 'crypto'
Module not found: Error: Can't resolve 'assert'
....etc.
If I run npm install or npm install dependencies I get the same result.
I stumbled across another question that the answer said to change the import statement to
import Web3 from 'https://cdn.esm.sh/v58/[email protected]/es2021/web3.js';
Which works in development….but when I turn it into a build package to deploy it
"The target environment doesn't support dynamic import() syntax so it's not possible to use external type 'module' within a script"
If I make a local file called web3 with the content from the cdn link from above I get the same "Can't resolve" errors as in the first situation.
Best Answer
That should install your missing dependencies and compile properly