question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[ionic v4] build for browser. Could not find cordova.js script tag.

See original GitHub issue

Bug Report

Ionic version: [x] 4.12.0

Current behavior: My project offers Android, web services as ionic. I used v3 and I recently migrated to v4.

Android is no problem. The web service uses firebase hosting, and the following error is displayed on the console. Could not find cordova.js script tag. Plugin loading may fail. This.platform.is(‘cordova’) also returns true.

This does not occur in the development environment (local deployment).

Expected behavior: On the web, this.platform.is(‘cordova’) should be false. And cordova_plugins.js should not be added automatically.

Steps to reproduce: We have built the following for web deployment: ionic cordova build browser --prod

Other information: After the build, the script is added automatically as shown below. platforms/browser/www/index.html

<script type="text/javascript" src="runtime.2e60a16c6e117d385511.js"></script><script type="text/javascript" src="es2015-polyfills.b6a15bd967a1a7dbe1a0.js" nomodule></script><script type="text/javascript" src="polyfills.3b992854afcaadf84bec.js"></script><script type="text/javascript" src="cordova.be00a3c9f5babbb22844.js"></script><script type="text/javascript" src="main.d1dd04adbe6dd750e532.js"></script>

After the deploy, cordova_plugins.js was added automatically in the head tag.

<script src="cordova_plugins.js"></script>

Ionic info:

Ionic:

   ionic (Ionic CLI)             : 4.12.0 (/usr/local/lib/node_modules/ionic)
   Ionic Framework               : @ionic/angular 4.1.1
   @angular-devkit/build-angular : 0.13.5
   @angular-devkit/schematics    : 7.2.4
   @angular/cli                  : 7.3.5
   @ionic/angular-toolkit        : 1.4.0

Cordova:

   cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1)
   Cordova Platforms     : android 8.0.0, browser 5.0.4
   Cordova Plugins       : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 3.1.2, (and 17 other plugins)

System:

   Android SDK Tools : 26.1.1 (/Users/hscho/Library/Android/sdk)
   ios-deploy        : 1.9.2
   ios-sim           : 6.1.2
   NodeJS            : v10.12.0 (/usr/local/bin/node)
   npm               : 6.9.0
   OS                : macOS Mojave
   Xcode             : Xcode 10.2.1 Build version 10E1001

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
gudtkd928commented, Jun 20, 2019

I misunderstood your answer. I understood you to say the following: Do not use cordova to develop web application. for web application, redevelop without cordova. Sorry.

The issue is resolved using:

ionic build --prod

thank you.

1reaction
kensodemanncommented, Jun 19, 2019

@gudtkd928 - I just noticed you are using Cordova’s browser platform. That is not really a good practice for deploying a web application. Instead, you should develop your application to use Cordova plugins in a cordova context (this.platform.is('cordova')) and a web API in a non-cordova context.

The browser platform is more or less a “testing” platform and not really something that is good for deployment. Many plugins do not work with the browser platform, and others provide fake testing data when used with the browser platform. Web APIs, or using Capacitor instead of Cordova, are far better options if you want to do a web deployment and target browsers as well as doing a hybrid native implementation.

If you want to target the browser without a hybrid native target (which I have done with a couple of apps), then I would remove the Cordova layer entirely and just use web APIs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Could not find cordova.js script tag. Plugin loading may fail.
I'm running Ionic v4-b11 and Cordova Android 7.1.1. I've tried putting <script src="cordova.js"></script> into my index.html page, ...
Read more >
Ionic V4 - Build Prod "Could not find cordova.js script tag ...
In dev environment the address is cordova.js and the file is found. In prod the file name gets hashed into something like ...
Read more >
cordova-js - npm
The build-tools/build.js process is a Node.js script that concatenates all of the core Cordova plugins in this repository into a cordova.
Read more >
Cordova.Js File Not Working - ADocLib
Description: start a new project width ioniccli type is cordova add some usual plugins run on Could not found cordova.js script tag Plugin...
Read more >
ionic cordova_not_available | The AI Search Engine You Control
Cordova is only included when you are running natively on a device, not when serving development version to a browser. Therefore cannot be...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found