12

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?

Cedervall
  • 1,309
  • 2
  • 13
  • 20
  • 12
    Make sure you don't have any packages using dotnet 6 versions. run `dotnet list package --outdated` (thanks to @StevenTCramer for the tip) – Mister Magoo Nov 19 '22 at 02:34
  • Had the same error. After clearing browsing data by using Chrome settings site started functioning. – Cenk Dec 28 '22 at 11:44

3 Answers3

6
  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"

Ctrlanton
  • 61
  • 1
  • 3
2

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)

Tobias
  • 21
  • 4
1

According to this issue the problem is having some outdated packages as stated by @Mister Magoo. Updating WebAssembly did the trick for me.

Kevo
  • 11
  • 1