I have updated my code from dotnet 6 to dotnet 7. It builds and everything looks fine until i run it. Then i get the error message:
Uncaught SyntaxError: Cannot use 'import.meta' outside a module (at dotnet.7.0.0.amub20uvka.js:8:27)
Any ideas?
I have updated my code from dotnet 6 to dotnet 7. It builds and everything looks fine until i run it. Then i get the error message:
Uncaught SyntaxError: Cannot use 'import.meta' outside a module (at dotnet.7.0.0.amub20uvka.js:8:27)
Any ideas?
Update outdated packages
Clear cache
If you have users and they have old cached files,try adding a query string in the script tag for blazor.webassembly.js in index.html
Example: src="_framework/blazor.webassembly.js?v=20230301"
Things you can try:
Check your dotnet version in project.csproj:
<TargetFramework>net7.0</TargetFramework>
Check your versions in project.csproj for:
Microsoft.AspNetCore.Components.WebAssembly
and
Microsoft.AspNetCore.Components.WebAssembly.DevServer
(This point solved my problem last time for me)
According to this issue the problem is having some outdated packages as stated by @Mister Magoo. Updating WebAssembly did the trick for me.