简体   繁体   中英

How to update cordova.js?

I need to update cordova.js in order to have issue CB-7868 fixed on a Cordova project of mine.

I ran all commands stated in this post but I can't get cordova.js updated.

My Cordova project is for the Android platform.

You have to manually update NPM package with fix, or wait for next tools release (later then Nov 13)

  • If you will wait for next release then you should run cordova platform update android

  • If you want to one-time patch then you have to replace content of platforms/android/assets/www/cordova.js with your patched version, or modify that file according to your needs.

  • If you want to permanently have manually patch then you have to do following steps.

    a) Open cordova NPM package where it is stored by NPM.

    On Windows : %appdata%\\npm-cache\\cordova-js

    On Linux ~/.npm/cordova-js

    b) Inside that you will see specific version of Cordova, 3.7.1 for example.

    c) Inside that folder package.tgz, unpack it content to another folder, let's use ~/cordova-js-modified for reference.

    d) Modify file package/cordova.js according to your needs and save.

    e) Repack content of ~/cordova-js-modified to package.tgz and place it again in the 3.7.1 folder.

    f) Now you will have modified version which will be applied each time you run cordova commands.

I ended up doing as follows

  • copy platforms/android/assets/www/cordova.js to www/cordova.patched.js ;
  • edit www/cordova.patched.js to replace clobber function with the updated one from cordova-js@3.7.2 ;
  • edit www/index.html to link cordova.patched.js instead of cordova.js ;
  • run cordova prepare android .

I also put a console.warn to remember I'm using a patched version of cordova.js .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM