Webpack Error: Module build failed: Error: Environment [object Object] not supported

694 views Asked by At

I am getting a string of errors when I build a module with Webpack. I can't find any documentation to suggest what this error means.

Webpack Error: Module build failed: Error: Environment [object Object] not supported

One of the libs loaded by the module contains a lib directory with React components, each of which has a stylesheet associated with it. There is one error for each stylesheet. Here is one of the errors in full:

ERROR in ./~/css-loader?{"localIdentName":"[name]__[local]--[hash:base64:5]","minimize":true}!./~/postcss-loader!../some-lib/lib/plugins/importGalleryImages/components/ItemList/ItemList.css
Module build failed: Error: Environment [object Object] not supported
    at module.exports (/Users/me/Documents/Personal/Code/Repos/project/webpack.server.config.js:94:9)
    at /Users/me/Documents/Personal/Code/Repos/project/node_modules/postcss-load-config/index.js:58:50
 @ ../some-lib/lib/plugins/importGalleryImages/components/ItemList/ItemList.css 4:14-185
 @ ../some-lib/lib/plugins/importGalleryImages/components/ItemList/ItemList.js
 @ ../some-lib/lib/plugins/importGalleryImages/components/Renderer/Renderer.js
 @ ../some-lib/lib/plugins/importGalleryImages/config.js
 @ ../some-lib/lib/index.js
 @ ./app/js/server.jsgogh/lib/plugins/importGalleryImages/components/ItemList/ItemList.css 4:14-185
     @ ../sb-van-gogh/lib/plugins/importGalleryImages/components/ItemList/ItemList.js
     @ ../sb-van-gogh/lib/plugins/importGalleryImages/components/Renderer/Renderer.js
     @ ../sb-van-gogh/lib/plugins/importGalleryImages/config.js
     @ ../sb-van-gogh/lib/index.js
     @ ./app/js/server.js

My Webpack config concerning stylesheets is:

 {
    module: {
      rules: [
        {
          test: STYLES_REGEX,
          include: includePaths,
          exclude: globalPath,
          // Extract CSS
          loader: ExtractTextPlugin.extract({
            fallbackLoader: 'style-loader',
            // Note: that there is no need for styles-loader as we don't want to convert styles
            // to JS
            loader: [
              {
                loader: 'css-loader',
                options: {
                  // Use CSS Modules
                  modules: useModules,
                  localIdentName: '[name]__[local]--[hash:base64:5]',
                  // Minimise output using cssnano.
                  // Note: An object can also be passed containing config options
                  minimize: true,
                },
              },
              {
                loader: 'postcss-loader',
              },
            ],
          }),
        },
      ],
    },
  };
1

There are 1 answers

1
Mati On

You have to upgrade both extract-text-webpack-plugin and webpack. More info here