Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting 'import.meta' error when updating blazor app to dotnet 7

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?

like image 670
Cedervall Avatar asked Jan 29 '26 09:01

Cedervall


2 Answers

  1. Update outdated packages

  2. Clear cache

  3. 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"

like image 80
Ctrlanton Avatar answered Jan 31 '26 18:01

Ctrlanton


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)

like image 33
Tobias Avatar answered Jan 31 '26 19:01

Tobias



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!