So I was following the tutorial on http://webpack.github.io/docs/tutorials/getting-started/ and I was stuck on the css style loader step. Here is my entry.js:
require("!style!css!./style.css");
document.write(require("./content.js"))
this is content.js:
module.exports = "It works from content.js";
this is style.css:
body{
background: yellow;
}
After this, I am running this command:
webpack ./entry.js bundle.js
I am getting this error:
Version: webpack 1.13.0 Time: 866ms Asset Size Chunks Chunk Names bundle.js 10.1 kB 0 [emitted] main [0] ./entry.js 115 bytes {0} [built] [4] ./content.js 45 bytes {0} [built] + 3 hidden modules
ERROR in ./~/css-loader!./style.css Module build failed: ReferenceError: Promise is not defined at LazyResult.async (/var/www/html/webpack/node_modules/css-loader/node_modules/postcss/lib/lazy-result.js:157:31) at LazyResult.then (/var/www/html/webpack/node_modules/css-loader/node_modules/postcss/lib/lazy-result.js:79:21) at processCss (/var/www/html/webpack/node_modules/css-loader/lib/processCss.js:198:5) at Object.module.exports (/var/www/html/webpack/node_modules/css-loader/lib/loader.js:24:2) @ ./~/style-loader!./~/css-loader!./style.css 4:14-73
How to fix this?
As mentioned in the comments, your version of Node is very old (in fact, support for v0.10.x is being dropped in October). Support for native JavaScript Promise
objects wasn't added until Node v4, and as suggested by the error message you posted, css-loader
makes use of these behind the scenes.
So the only real solution to this issue is to update Node. There are two versions that you can choose from at the moment; v4 is the most stable but lacks some newer features, whereas v6 has the latest features but might be more buggy/less well supported.