A Chrome App I've made works perfectly fine for me, but another user gets an error Uncaught ReferenceError: Promise is not defined when starting it up. For some reason it doesn't understand what a Promise is. The code works perfectly fine on my end and I've never gotten that error before, but the user gets it every time. What could be the issue here?

有帮助吗?

解决方案

The user updated Chrome to the latest version and that apparently fixed it. I don't know how, since his version was from December 2013 and surely Promises worked back then. I don't know. It definitely isn't a problem with the code since I'm running the same exact version the user is running and I've never encountered that error.

But yeah - apparently fixed.

EDIT: Apparently Promises only work since Chrome 32, so yeah that's why the error.

其他提示

To support IE and older versions of other browsers, you should consider loading a polyfill for the Promise object.

One implementation you can use out of the box with a <script> tag is available here.

Primise in Old Browsers

​Android 4.x browser Promise

I had similar problem ​in Android 4.X browsers. I solved it by using es6-promise in webpack config: ​ ​Promise: 'es6-promise' ​

​plugins: [
    ​    //tells webpack where to store data about your bundles.
    ​    new BundleTracker({filename: './webpack-stats.json'}),        ​
    ​    //makes jQuery available in every module
    ​    new webpack.ProvidePlugin({
    ​        $: 'jquery',        ​
    ​        jQuery: 'jquery',
    ​        'window.jQuery': 'jquery',
    ​        Promise: 'es6-promise'
    ​    }),
​    // Configure path for served CSS files ("desktop_css" will be served as /dist/desktop_css.css)    ​
​    new ExtractTextPlugin('[name].css'),    ​
​],

Can I use Promise: ​http://caniuse.com/#feat=promises


some related links:

​​axios IE promise doesn't work

https://github.com/axios/axios/issues/188

https://github.com/webpack/webpack/issues/4254

Not an expert in this field, but maybe this will help someone.

Got the same issue on Cordova Android app on Android 4.4.

Fixed by running this commands

 1. cordova plugin rm cordova-plugin-inapppurchase --save
 2. cordova plugin add https://github.com/AlexDisler/cordova-plugin-inapppurchase#1968e41d173481eb2e6a536fdc55cc9e9253e6d5 --save 
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top