Css-loader: Module build failed: ReferenceError: Promise is not defined

Created on 24 Sep 2015  路  34Comments  路  Source: webpack-contrib/css-loader

Hi all,

I try to update some of my npm packages, and then I'm having this issues.

ERROR in ./~/css-loader!./~/sass-loader!./src/style/components/home.scss
Module build failed: ReferenceError: Promise is not defined
    at LazyResult.async (/Users/roy/development/stash/chaas-web/node_modules/css-loader/node_modules/postcss/lib/lazy-result.js:152:31)
    at LazyResult.then (/Users/roy/development/stash/chaas-web/node_modules/css-loader/node_modules/postcss/lib/lazy-result.js:75:21)
    at processCss (/Users/roy/development/stash/chaas-web/node_modules/css-loader/lib/processCss.js:174:5)
    at Object.module.exports (/Users/roy/development/stash/chaas-web/node_modules/css-loader/lib/loader.js:22:2)
 @ ./src/style/components/home.scss 4:14-127 13:2-17:4 13:2-17:4 14:20-133

And the following is my package.json

  "devDependencies": {
    "assets-webpack-plugin": "2.2.x",
    "babel-jest": "5.3.x",
    "css-loader": "0.19.x",
    "file": "0.2.x",
    "file-loader": "0.8.x",
    "html-webpack-plugin": "1.6.x",
    "image-webpack-loader": "1.6.x",
    "imagemin": "3.2.x",
    "jest-cli": "0.5.x",
    "jsx-loader": "0.13.x",
    "node-sass": "3.3.x",
    "react-hot-loader": "1.3.x",
    "react-proxy-loader": "0.3.x",
    "react-tools": "0.13.x",
    "sass-loader": "2.0.x",
    "style-loader": "0.12.x",
    "webpack": "1.12.x",
    "webpack-dev-server": "1.11.x"
  },

And this is my webpack config for the scss

{ test: /\.scss$/, loader: "style-loader!css-loader!sass-loader" }

Anyone have idea and much appreciated, thanks.

Most helpful comment

@Strate I got it to work by downgrading css-loader to "^0.18.0"

All 34 comments

same
+1

+1

+1

Is there any quick workaround?

@Strate I got it to work by downgrading css-loader to "^0.18.0"

+1

+1, @nazywamsiepawel, same. Seems to be exclusive to 0.19.0

+1 @nazywamsiepawel . Your workaround works.

@nazywamsiepawel thnx, that did the trick

I fixed problem by switching to node version 0.12.7 I guess 0.19.0 uses a dependency that breaks on node 0.10?

It's a bit frustrating as my older projects can't use 0.12 so I'll have to switch back to 0.10 when I switch projects.

Had the same problem. Realized I had Node v0.10.26 (gosh!) installed. Upgraded to latest stable version (v4.2.1) and the problem was fixed.

Thanks @andre-gh .. Works !!

I upgraded my node to v0.12.7 and it worked.

@andre-gh thanks - the workaround works perfectly!

@andre-gh thank you for saving my day

I'm getting this on node v5.3.0

@andre-gh Thanks man!

I got this problem on node: '0.10.40'.
To upgrade node version to node: '4.2.4' , solve this problem.

Had the same problem. Realized I had Node v0.10.29 (gosh!) installed

I'am I did downgrade of nodejs 0.10 to v5.3.0

on ubuntu:

sudo apt-get remove nodejs

Install nodeJS v5.3.0:
curl -sL https://deb.nodesource.com/setup_5.x | sudo -E bash -
sudo apt-get install -y nodejs

I can't upgrade锛孴oo many project dependencies

@nazywamsiepawel thank you

@yanhaijing I believe in you! Don't let your dreams be dreams!!

Closing as this is a duplicate of https://github.com/webpack/css-loader/issues/144, as mentioned already by @ben-eb. He also proposed a solution for those stuck on older versions of Node, by polyfilling global.Promise.

@philihp thank you

Thanks @nazywamsiepawel - am in the same boat as others where I can't upgrade.

Upgrading to node 0.12.x works too, in case you can't make the leap to 4.

Downgrading css-loader worked.

Thanks guys, I'm had the same problem. Upgrading to Node v6.2.2 works perfectly !!

// first line of webpack.config.js
global.Promise = require('bluebird')

if you already have bluebird.

The same problem here, with
node 6.2.1
css-loader 0.23.1

Workaround suggested by @andre-gh

require('es6-promise').polyfill() in your webpack config

works for me too

@fhurta Same for me. npm install es6-promise --save and then added require('es6-promise').polyfill() at the top of webpack.config.js.

You can use Promise: 'es6-promise' in your webpack config:
```
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'),
],

```

https://stackoverflow.com/questions/35769777/axios-ie-promise-doesnt-work/48203092#48203092

I had this in Android 4.x browsers and about using axios And Promise there.

Was this page helpful?
0 / 5 - 0 ratings