Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Cannot resolve module [object Object] #215

Closed
raphaklaus opened this issue Jul 18, 2016 · 16 comments
Closed

Cannot resolve module [object Object] #215

raphaklaus opened this issue Jul 18, 2016 · 16 comments

Comments

@raphaklaus
Copy link

Hi there! I'm trying to execute a webpack with extract-text, but I'm getting "Cannot resolve module '[object Object]'".

Here is a fragment.

    loaders: [{
      test: /\.css$/,
      loader: ExtractTextPlugin.extract({
        notExtractLoader: "style-loader",
        loader: "css-loader"
      })
    }]

Version of this plugin: 1.0.1
Node: 6.2.0. Tested in 4.4.0. And the same.

@raphaklaus
Copy link
Author

Well, for some reason version 1.0.1 doesn't works with webpack 1.x
I've upgraded to extract-text-webpack-plugin@v2.0.0-beta.2 and webpack@v2.1.0-beta.19 and worked perfectly.

@Eschon
Copy link

Eschon commented Jul 25, 2016

Hi I'm having the same issue. I also use version 1.0.1 and my node version is 6.2.2.
Using v2.0.0-beta.2 or v2.0.0-beta.3 won't work for me because of #214

Here's the loader config for the plugin:

{
  test: /\.css$/,
  loader: ExtractTextPlugin.extract({
    fallbackLoader: 'style-loader',
    loader: 'css-loader!postcss-loader'
  })
}

Please let me know if I can supply any additional information for resolving this issue.

@Eschon
Copy link

Eschon commented Jul 25, 2016

I managed to fix it by changing my loader config to

{
  test: /\.css$/,
  loader: ExtractTextPlugin.extract('style', 'css-loader!postcss-loader')
}

Still I think there is an issue that should be resolved, because my initial config was pretty similar to what you have in the README.md

@Jessidhia
Copy link
Contributor

Jessidhia commented Jul 25, 2016

You have to upgrade both extract-text-webpack-plugin to ^v2.0.0-beta.3 and webpack to ^v2.1.0-beta.19 to fix #214. ExtractTextPlugin.extract('style', 'css-loader!postcss-loader') only works at all on older extract-text-webpack-plugin.

@Eschon
Copy link

Eschon commented Jul 25, 2016

@Kovensky I know that #214 would have been fixed if I switched to the newest webpack beta but I don't like using beta versions of packages in production if I can avoid it.

And ExtractTextPlugin.extract('style', 'css-loader!postcss-loader') works without problems in extract-text-webpack-plugin@1.0.1

@narek11
Copy link

narek11 commented Jul 25, 2016

@Kovensky doesn't ExtractTextPlugin.extract accept only a single config argument ?

@Jessidhia
Copy link
Contributor

@narek11 yes, as of the version 2 beta, and it complains at you if you do give more than one argument. Previous versions accept (up to) 3 arguments.

@arahansen
Copy link

I'm having this issue as well on webpack@1.13.1 and extract-text-webpack-plugin@1.0.1

I would rather not upgrade to either beta right now (upgrading webpack broke my build). Is there a workaround for this issue? Should I revert the plugin to an earlier version? @Eschon 's proposed fix didn't seem to do it for me.

@Jessidhia
Copy link
Contributor

Use the documentation from the webpack-1 branch when using the 1.x version: https://github.com/webpack/extract-text-webpack-plugin/blob/webpack-1/README.md

@GarryFlemings
Copy link

GarryFlemings commented Sep 13, 2016

I'm in exactly the same position as raphaklaus was Jul 17: Node 6.2.0, extract-text-webpack-plugin@1.0.1. When using the fragment he used, I got the same error message he got.

npm tells me to get answers at https://github.com/webpack/extract-text-webpack-plugin. Given that npm gave me v1.0.1, I followed the link to https://github.com/webpack/extract-text-webpack-plugin/blob/webpack-1/README.md. As I understood it, it told me to switch to the syntax Eschon used on Jul 25.

First, npm told me to install webpack-load-plugins. After that, npm went back to telling me to get answers at https://github.com/webpack/extract-text-webpack-plugin. So Eschon's syntax isn't working for me and I'm in the same position as arahansen on Jul 27: I need to use a stable release in production.

Do you have any idea of a condition that might have been present in Eschon's environment that I could reproduce and get this working? Is there a workaround? Thanks in advance.

@GarryFlemings
Copy link

New report. I got a workaround to work. See my documentation here.

@RyanCCollins
Copy link

I got into this same bind, wasn't able to update to the latest v of webpack and @Prairie-Falcon's guide saved me. Kudos!!

@ixcviw7bw
Copy link

Not sure if this will help, but in my case this was caused by having these lines in webpack config:

module.exports = {
  resolve: { fallback: path.join(__dirname, "node_modules") },
  resolveLoader: { fallback: path.join(__dirname, "node_modules") }}
...

Removing them fixed the problem.

@TNT-Likely
Copy link

@raphaklaus not work when i update extract-text-webpack-plugin to 2.0.0-beta.2,show errors
qq20161228-1
0702035e-62c4-417c-803d-b12a71b190e1

@alilland
Copy link

having issue with webpack v1.14.0 & extract-text-webpack-plugin v1.0.1 on windows when running webpack --watch within my react application .jsx file

// webpack.config.json
{
  // . . .
  module: {
     loaders: [
      {
        test: /\.jsx?$/,
        loader: 'babel-loader'
      },
      {
        test: /\.scss$/,
        loader: ExtractTextPlugin.extract({
          fallbackLoader: 'style-loader',
          loader: 'css-loader!sass-loader'
        })
      }
    ]
  },
  plugins: [
    new ExtractTextPlugin('./public/style.css')
  ]
}

Error output in terminal:

ERROR in ./src/Index.jsx
Module not found: Error: Cannot resolve module '[object Object]' in C:\Users\ALilland\Documents\application\src
 @ ./src/Index.jsx 15:0-26

@wheelerlaw
Copy link

@TNT-Likely Did you add the ExtractTextPlugin plugin to the list of plugins? Do something like this in your webpack.config.js:

config.plugins = [
    new ExtractTestPlugin('css/[name].[hash].css'),
    <other plugins>
]

@aronlmin You are using the wrong syntax for the extract method call. The syntax you are using is for the latest version of the extract-text-webpack-plugin. For version 1, change it to look like this:

loader: ExtractTextPlugin.extract('style-loader', 'css-loader!sass-loader')

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests