Uncaught SyntaxError: Cannot use import statement outside a module
SuperCS92 opened this issue ยท 5 comments
Hello,
Thank you very much for this tutorial. When adding ' import MetaMaskOnboarding from '@metamask/onboarding' on contract.js as appears in the index.js in the finished directory, the console throws this message ' Uncaught SyntaxError: Cannot use import statement outside a module '. It is not a problem with your code, but I can not run the tutorial because of this error. I'm assuming you are not having this problem or you solved it, either way, hope you can help, I don't know if I'm the only one having this problem.
I'm sorry if I'm misusing this channel, is the first issue I report.
Hmmm, I'll check it out! ๐ Thanks for posting this!
@SuperCS92 I inspected index.html
and it looks like the project is importing @metamask/onboarding with the prebuilt ES5 bundle <script src="node_modules/@metamask/onboarding/dist/metamask-onboarding.bundle.js" defer></script>
WHICH means you can use the global variable MetamaskOnboarding
without importing it, i.e just do const onboarding = new MetamaskOnboarding({ forwarderOrigin });
Note: the prebuilt es5 bundle defines MetamaskOnboarding
with a lower case M, not MetaMaskOnboarding
@BboyAkers Maybe change the tutorial to use MetamaskOnboarding
instead of MetaMaskOnboarding
?
@alyforalyssa I'll update it! Thanks!!๐๐ ๐
any fix for this yet?