Node/Express - Refused to apply style because its MIME type ('text/html')

后端 未结 5 1110
孤城傲影
孤城傲影 2020-12-15 22:24

I\'ve been having this issue for the past couple of days and can\'t seem to get to the bottom of this. We doing a very basic node/express app, and are trying to serve our st

5条回答
  •  自闭症患者
    2020-12-15 22:33

    Though the answer has to do with a space in the file, I have another potential answer that also generates the same error code. I'm posting it here as it also brings up this common error that gets a lot of looks.

    The alternative is the misplacement of the styles.css file. If it is not present where it is referenced, Chrome will spit out the same error code.

    I've had an instance of the styles.css being in an express js's "public" folder but not in the actual "css" sub-folder in "public." (public was used as the static folder.)

    If you use VS Code, your document view in the left pane has this weird visual display that can fool you into thinking the styles.css is in the "css" folder when in fact it is not. I only discovered the issue after using normal windows explorer and seeing the missplaced file. To fix, check and if missplaced, just put styles.css where it should be.

    Hope this helps others too!

提交回复
热议问题