1

I'm trying to serve an Angular application (Angular 8.2.14) from a server written in Go.

Searching around I found the following snippet that supposedly makes the trick.

func main() {
    http.ListenAndServe(":4000", http.FileServer(http.Dir(folderDist)))
}

Where folderDist is the directory where I made ng build of my application.

When I navigate to localhost:4000 in my examples, I receive on the browser the following errors:

runtime-es2015.js:1 Failed to load module script: The server responded with a non-JavaScript MIME type of "text/plain". Strict MIME type checking is enforced for module scripts per HTML spec.
styles-es2015.js:1 Failed to load module script: The server responded with a non-JavaScript MIME type of "text/plain". Strict MIME type checking is enforced for module scripts per HTML spec.
main-es2015.js:1 Failed to load module script: The server responded with a non-JavaScript MIME type of "text/plain". Strict MIME type checking is enforced for module scripts per HTML spec.
polyfills-es2015.js:1 Failed to load module script: The server responded with a non-JavaScript MIME type of "text/plain". Strict MIME type checking is enforced for module scripts per HTML spec.
vendor-es2015.js:1 Failed to load module script: The server responded with a non-JavaScript MIME type of "text/plain". Strict MIME type checking is enforced for module scripts per HTML spec.

What am I missing?

I've tried the solution suggested here, but the errors are still the same.

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
Nilo Paim
  • 428
  • 6
  • 22

1 Answers1

1

Solved.

Apparently there is a bug in some versions of Angular 8...

Edit tsconfig.json file and changes the line "target" to "es5".

"target": "es5",

Make "ng build".

Done!

Nilo Paim
  • 428
  • 6
  • 22