'Reactjs : Failed to load module script: WIth MIME type "application/octet-stream" for sharepoint webpart
I'm using reactjs project for use as a webpart for the sharepoint project. But when i deploy the build project. It give me below error.
Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "application/octet-stream". Strict MIME type checking is enforced for module scripts per HTML spec.
here is the image of console too.
I have created reactjs project using vitejs for more understanding.
Thanks
Solution 1:[1]
First I restarted the dev server but that didn't worked for me.
Then I used the command sudo killall node
and then again started the dev server. I don't know why but it did worked for me.
Solution 2:[2]
I had the issues such as your error when I use table component from https://unpkg.com/browse/[email protected]/dist/antd.js.
My code is ...
<pre>
import React, { useState, useEffect } from "https://unpkg.com/es-react@latest/dev/react.js";
import ReactDOM from "https://unpkg.com/es-react@latest/dev/react-dom.js";
import htm from "https://unpkg.com/htm@latest?module";
import { Table } from 'https://unpkg.com/browse/[email protected]/dist/antd.js';
....
const columns = [{...}];
const data = [{...}];
function App() {
return htm.bind(React.createElement)`
<div className="App">
<${Table} columns=${columns} dataSource=${data} />
</div>
)`;
}
ReactDOM.render(
htm.bind(React.createElement)`<${App} />`,
document.getElementById("root")
);
</pre>
I didn't fix this issues yet. This seems be related with mime script problem.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Swaroop Rajwal |
Solution 2 | Senior Dev |