I am using the following version of IONIC and Cordova;
IONIC;
1.5.5
Cordova;
5.1.1
Build my mobile application.
But when ever I finish building it and run it I keep getting the following exception:
Uncaught module cordova-plugin-file.ProgressEvent not found
Could someone please help me out ?.
I had the same issue today and in my case this was because the version of the file-transfer plugin was not compatible with the File plugin I use.
The file transfer plugin requires the cordova-plugin-file.ProgressEvent (see FileTransfer.js in the file transfer plugin directory)
But if you're still using an older version of the file plugin (in my case org.apache.cordova.file instead of cordova-plugin-file) then it can't resolve that.
So either you update your plugins so you use the cordova-file-plugin or you change the code of the FileTransfer plugin, this is not advised because when the plugins are reinstalled you will loose this change. But if for whatever reason you can't use the newer file plugin you can use this method.
On line 25 of the FileTransfer.js file change
ProgressEvent = require('cordova-plugin-file.ProgressEvent');
to
ProgressEvent = require('org.apache.cordova.file.ProgressEvent');
If that doesn't solve it, try to look up the correct module name in your File plugin directory's config.xml file (look for the ID property) and use that instead (don't forget to append ProgressEvent)
To elaborate on my point of not changing the code of the FileTransfer plugin you can however copy the plugin code and put it somewhere on your disk and use that plugin instead of the hosted one (which is loaded and used if you just use the plugin's ID)
Related
Problem
I want to add an optional configuration file to my expo app.
What I've tried
I tried to include the file like this:
const url = require('./config.json').url
This works if the file exists, but it has to also work when it doesn't exist. If I now delete the file, I can't compile my application since require resolves before runtime. Surrounding it with try-catch doesn't work either.
I also tried optional-require and require-optional from npm, but both require libraries not available in a react native app.
Goal
I would prefer to avoid filesystem checks and resolve it statically, but it needs to gracefully abort if the file doesn't exist.
Include a config_example.json file in your repo. Copy it to config.json at startup.
Maybe a newbie-question:
Why does my WebStorm IDE not recognize any jQuery code when on the other side the created page works well in the browser?
That's what I did:
I've installed WebStorm Version 2018.2.6.
Then I downloaded a simple jQuery demo project, this one:
http://javascriptbook.com/code/c07/example.html (the html-file, the css file and the .cs file).
Then I downloaded a minified jQuery, "jquery-3.3.1.min.js".
I put all the files in a folder, changed the relative paths and updated the jQuery filename, so in the html file it reads "<script src="jquery-3.3.1.min.js"></script> <script src="code.js"></script>"
When I view that via WebStorm (=when I launch Chrome and WebStorm provides the webserver), then everything works perfectly. Animation is done just nicely.
However, in the WebStorm IDE all occurrences of the $ operator in the .js file are marked as "unresolved function".
I found these articles:
phpstorm unresolved function or method $()
I can't add jQuery to WebStorm, why?
So I went to Languages & Frameworks | JavaScript | Libraries and download&installed "jquery". It's then listed as "#types/jquery".
However, the error highlighting is still there.
Do I need to make more source mofications or how do I get that working?
Types resolving won't work when using minified library version, but downloading typings (#types/jquery) should work:
make sure that the library is downloaded properly (can you see it in External libraries list in the Project tool window?); invalidating caches (File | invalidaate caches, Invalidate and restart) can also help
I was trying to run the demo for bootstrap-timepicker, the demoe references
jquery.min.js but from the JQuery download I got jquery-1.12.4.min.js .
What is the process in this case, is it to be understood to download the latest version and rename it to jquery.min.js or to change the reference from jquery.min.js to jquery-1.12.4.min.js.
I know using Bower would automagically get everything is needed but 1.My companies proxy settings was causing bower to time out and 2.Just want to know why a demo that is most likely is used by many correctly is pointing to a file that is not downloadable manually from JQuery site
You can do whatever you want in your own server. Keeping the version number will allow you to download multiple versions, in case your applications have version dependencies. If you rename it to jquery.min.js then you need to be very careful about upgrading it, because it could potentially break some applications if there's an incompatible change in the new version.
The demo probably doesn't use a version number because they didn't want readers to think it was dependent on a specific version.
I am new to Javascript and am interested in using a library from github. I am using netbeans to code and I have installed node.js. However, I am still getting the error 'Require is not defined'. I have installed 'browserify' as this seemed like a common solution, but I am still getting this error.
Am I doing something wrong?
Image of set up libraries
Update
I have also found that there is a problem with one of my libraries, think it could be relevant to the original problem.
Problem with library
If you are developing NodeJS based project, you should use NodeJS project type in NetBeans where require() is considered as known global function and as such NetBeans won't show the hint.You can change your current project to enable NodeJS support by right clicking on the project, select Project Properties -> NodeJS and check Enable NodeJS support.
If you are using RequireJS library, you can also enable RequireJS support in Project Properties in JavaScript Frameworks -> RequireJS
I guess this is because require() does not exist in the browser/client-side JavaScript.Can you give it a try to following statements;
Use <script> tag.
Use a CommmonJS implementation. Synchronous
dependencies like Node.js
Use an AMD implementation.
And keep library codes and application codes seperated. ( bundle.js and script.js )
Browserify will take all the script files necessary and put them into the "bundle.js" file, so you should only have to include "bundle.js" in the HTML file, not the "script.js" file.
I installed phonegap 3.3.0 via the command line, created app, added android platform OK. I can use the latest Android ADT to import phonegap app and test it on my Android device. Everything worked perfect.
I installed the Email Composer plugin https://github.com/katzer/cordova-plugin-email-composer via the command line
cordova plugin add https://github.com/katzer/cordova-plugin-email-composer.git
The plugin seems install ok, however when I tried to run the javascript code
window.plugin.email.open();
I got error
Uncaught TypeError: Cannot call method 'open' of undefined:43
I put the email_composer.js inside js folder and in my index.html I add reference to it. Not sure why I get this error.
I already asked the author here https://github.com/katzer/cordova-plugin-email-composer/issues/9 and he answered:
You lead the plugin in the wrong way. Do not lead the plugins directly.
If you install a plugin through the command line interface,
they will be listed in the cordova_plugins.js file which is loaded
by cordova.js.
I looked up the file cordova_plugins.js I only saw these code:
cordova.define('cordova/plugin_list', function(require, exports, module) {
module.exports = [];
module.exports.metadata =
// TOP OF METADATA
{}
// BOTTOM OF METADATA
});
I should see something about email_composer.js in this file, right? If so, then what I should write in here.
This is my first time using phonegap plugin, not sure what to do. Hope someone can help
Thanks
Always remember to 'prepare' your app after installing any new plugin. From the app's root:
cordova prepare android
This should update your cordova_plugins.js file
I found the bug. I got error if I call the javascript like this
window.plugin.email.open();
To make it works, call like this:
window.plugin.open();
(remove "email")
Hope this help someone