sass-loader: Module build failed: TypeError: this.getResolve is not a function
- 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
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 2
- Comments: 20
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.
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).
Works for me, thank you so much @rbfonbuena
How to update webpack to the latest version?
THIS WORKED FOR ME!
npm install webpack@4.40.2
It’s happening to me with
webpack@4.41.2
.It appears to be related with the usage of
thread-loader
.When I use this loaders chain the error happens:
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: https://github.com/webpack-contrib/thread-loader/issues/79.