[SOLVED] F7 React: Failed to load module script

Hi everyone!
I’m in trouble right here.
I have build my react app when I install an android app my console showing this: Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "". Strict MIME type checking is enforced for module scripts per HTML spec.

When I open logcat for android, found this: 2021-08-07 11:23:13.472 23203-23203/****/chromium: [INFO:CONSOLE(0)] "Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "". Strict MIME type checking is enforced for module scripts per HTML spec.", source: file:///android_asset/www/assets/index.b8f6f455.js (0)

Have someone get in this trouble too?

I’m developed with f7 about years, and never get this, I’m in this about 3 or 4 days, my code looks fine … thinking that was something from build …

1 Like
{

  "name": "nyc",

  "private": true,

  "version": "1.0.0",

  "description": "NYC",

  "repository": "",

  "license": "UNLICENSED",

  "scripts": {

    "start": "npm run dev",

    "dev": "cross-env NODE_ENV=development vite",

    "build": "cross-env NODE_ENV=production vite build",

    "build-cordova": "cross-env TARGET=cordova cross-env NODE_ENV=production vite build && cd cordova && cordova build",

    "build-cordova-ios": "cross-env TARGET=cordova cross-env NODE_ENV=production vite build && cd cordova && cordova build ios",

    "cordova-ios": "cross-env TARGET=cordova cross-env NODE_ENV=development vite build && cd cordova && cordova run ios",

    "build-cordova-android": "cross-env TARGET=cordova cross-env NODE_ENV=production vite build && cd cordova && cordova build android",

    "cordova-android": "cross-env TARGET=cordova cross-env NODE_ENV=development vite build && cd cordova && cordova run android"

  },

  "browserslist": [

    "Android >= 7",

    "IOS >= 11",

    "Safari >= 11",

    "Chrome >= 49",

    "Firefox >= 31",

    "Samsung >= 5"

  ],

  "dependencies": {

    "dom7": "^3.0.0",

    "framework7": "^6.2.0",

    "framework7-react": "^6.2.0",

    "prop-types": "^15.7.2",

    "react": "^17.0.2",

    "react-dom": "^17.0.2",

    "skeleton-elements": "^3.4.0",

    "swiper": "^6.8.1"

  },

  "devDependencies": {

    "@vitejs/plugin-react-refresh": "^1.3.6",

    "cross-env": "^7.0.3",

    "postcss-preset-env": "^6.7.0",

    "sass": "^1.37.5",

    "vite": "^2.4.4",

    "vite-plugin-html": "^2.0.7"

  }

}

this is my package

This error can be caused by import/export. Make sure you import / export the right thing.

I have search the import/export things, but, not sure what is going on.
So I’ll create another project from zero to make sure what happened.

I dont know why, but try to create a new framework7 project from framework7 create --ui with REACT, and try to build to android, when install in a android app, appears like this

This happens even without a single modify

I found the solution … when I see the image, at url you can see that my file are hosted by file:// and modules can only be used as served, so, just need to add an webview like cordova-plugin-ionic-webview whose create a localhost server only by adding the plugin

3 Likes

thank you! same problem in core version