Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module build failed: TypeError: this.getResolve is not a function #761

Closed
VirtualAirwaves opened this issue Sep 17, 2019 · 7 comments

Comments

@VirtualAirwaves
Copy link

@VirtualAirwaves VirtualAirwaves commented Sep 17, 2019

  • Operating System: centos 7
  • Node Version: 6.17.1
  • NPM Version: 3.10.10
  • webpack Version: 4.4.0
  • sass-loader Version: 8.0.0

Expected Behavior

I expected my SASS to compile

Actual Behavior

Module build failed: ModuleBuildError: Module build failed: TypeError: this.getResolve is not a function
    at Object.loader (/home/famserve/cb/va_web/assets/node_modules/sass-loader/dist/index.js:52:26)
    at runLoaders (/home/famserve/cb/va_web/assets/node_modules/webpack/lib/NormalModule.js:244:20)
    at /home/famserve/cb/va_web/assets/node_modules/loader-runner/lib/LoaderRunner.js:367:11
    at /home/famserve/cb/va_web/assets/node_modules/loader-runner/lib/LoaderRunner.js:233:18
    at runSyncOrAsync (/home/famserve/cb/va_web/assets/node_modules/loader-runner/lib/LoaderRunner.js:143:3)
    at iterateNormalLoaders (/home/famserve/cb/va_web/assets/node_modules/loader-runner/lib/LoaderRunner.js:232:2)          at Array.<anonymous> (/home/famserve/cb/va_web/assets/node_modules/loader-runner/lib/LoaderRunner.js:205:4)
    at Storage.finished (/home/famserve/cb/va_web/assets/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:43:1
// webpack.config.js

`const path = require('path');                                                                                           const glob = require('glob');                                                                                           const MiniCssExtractPlugin = require('mini-css-extract-plugin');                                                        const UglifyJsPlugin = require('uglifyjs-webpack-plugin');                                                              const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');                                          const CopyWebpackPlugin = require('copy-webpack-plugin');                                                                                                                                                                                       module.exports = (env, options) => ({                                                                                     optimization: {                                                                                                           minimizer: [                                                                                                              new UglifyJsPlugin({ cache: true, parallel: true, sourceMap: false }),                                                  new OptimizeCSSAssetsPlugin({})                                                                                       ]                                                                                                                     },                                                                                                                      entry: {                                                                                                                    './js/app.js': ['./js/app.js'].concat(glob.sync('./vendor/**/*.js'))                                                },                                                                                                                      output: {                                                                                                                 filename: 'app.js',                                                                                                     path: path.resolve(__dirname, '../priv/static/js')                                                                    },                                                                                                                      module: {                                                                                                                 rules: [                                                                                                                  {                                                                                                                         test: /\.js$/,                                                                                                          exclude: /node_modules/,                                                                                                use: {                                                                                                                    loader: 'babel-loader'                                                                                                }                                                                                                                     },                                                                                                                      {                                                                                                                         test: /\.css$/,                                                                                                         use: [MiniCssExtractPlugin.loader, 'css-loader']                                                                      },                                                                                                                      {                                                                                                                         test: /\.elm$/,                                                                                                         exclude: [/elm-stuff/, /node_modules/],                                                                                 use: {                                                                                                                    loader: 'elm-webpack-loader',                                                                                           options: {                                                                                                                  debug: false                                                                                                        }                                                                                                                     }                                                                                                                     },                                                                                                                      {test: /\.scss$/,                                                                                                         use: [                                                                                                                      MiniCssExtractPlugin.loader,                                                                                            {                                                                                                                         loader: 'css-loader'                                                                                                  },                                                                                                                      {                                                                                                                         loader: 'sass-loader',                                                                                                  options: {                                                                                                                sourceMap: true                                                                                                       }                                                                                                                     }                                                                                                                     ]                                                                                                                   }                                                                                                                     ]                                                                                                                     },                                                                                                                      plugins: [                                                                                                                new MiniCssExtractPlugin({ filename: '../css/app.css' }),                                                               new CopyWebpackPlugin([{ from: 'static/', to: '../' }])                                                               ]                                                                                                                     });     `                                                                                           

How Do We Reproduce?

I have been unable to get this to work at all. There seems to be something fundamentally wrong with these versions, which I presume to be the latest. I can see the call to getResolve inside the source to sass-loader/index.js so I don't know why it wasn't defined

@VirtualAirwaves

This comment has been minimized.

Copy link
Author

@VirtualAirwaves VirtualAirwaves commented Sep 18, 2019

Figured it out! I didn't have the latest version of everything. I needed webpack 4.40.2 and it fixed it. (I think 4.36.x or later would work).

@yogiprsetya

This comment has been minimized.

Copy link

@yogiprsetya yogiprsetya commented Oct 17, 2019

I have same problem, how to fix it?

@hidaytrahman

This comment has been minimized.

Copy link

@hidaytrahman hidaytrahman commented Oct 21, 2019

How to update webpack to the latest version?

@ngryman

This comment has been minimized.

Copy link

@ngryman ngryman commented Nov 8, 2019

It's happening to me with webpack@4.41.2.

@ngryman

This comment has been minimized.

Copy link

@ngryman ngryman commented Nov 8, 2019

It appears to be related with the usage of thread-loader.

When I use this loaders chain the error happens:

[
  'style-loader',
  'thread-loader',
  'css-loader',
  'sass-loader'
]

However, if I remove thread-loader everything works fine. Here is a very simple repo to reproduce that issue: https://github.com/ngryman/thread-sass-loaders-bug.

I've also opened an issue in the thread-loader's repo as I'm not sure which package has the bug: webpack-contrib/thread-loader#79.

@rbfonbuena

This comment has been minimized.

Copy link

@rbfonbuena rbfonbuena commented Nov 16, 2019

Posting this in case a search sent someone here with the same issue. Downgrading from sass-loader 8.0.0 to 7.3.1 fixed it for me on new builds with Webpack 4.4.0.

@Legends

This comment has been minimized.

Copy link

@Legends Legends commented Nov 26, 2019

I have this error when I install webpack v4.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants
You can’t perform that action at this time.