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
RobertSwirsky opened this issue Sep 17, 2019 · 20 comments
Closed

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

RobertSwirsky opened this issue Sep 17, 2019 · 20 comments

Comments

@RobertSwirsky
Copy link

@RobertSwirsky RobertSwirsky 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

@RobertSwirsky
Copy link
Author

@RobertSwirsky RobertSwirsky 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
Copy link

@yogiprsetya yogiprsetya commented Oct 17, 2019

I have same problem, how to fix it?

@hidaytrahman
Copy link

@hidaytrahman hidaytrahman commented Oct 21, 2019

How to update webpack to the latest version?

@ngryman
Copy link

@ngryman ngryman commented Nov 8, 2019

It's happening to me with webpack@4.41.2.

@ngryman
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
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.

@blackbart420
Copy link

@blackbart420 blackbart420 commented Dec 7, 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.

Works for me, thank you so much @rbfonbuena

@Dhanush623
Copy link

@Dhanush623 Dhanush623 commented Dec 31, 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.

This works for me

@thefront2
Copy link

@thefront2 thefront2 commented Jan 28, 2020

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.

Thanks, works for me too

@sudamonline
Copy link

@sudamonline sudamonline commented Feb 29, 2020

How can we change or update the webpack verison?

@rainke
Copy link

@rainke rainke commented Mar 3, 2020

style-loader is ok, but MiniCssExtractPlugin.loader has the same error

[
  MiniCssExtractPlugin.loader,
   'thread-loader',
   'css-loader', 
  {
    loader: 'sass-loader', 
    options: { implementation: require('sass') }
  }
]

@graciolli-f
Copy link

@graciolli-f graciolli-f commented Mar 4, 2020

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.

Thank you so much for this!!!

@ValentinnDimitroff
Copy link

@ValentinnDimitroff ValentinnDimitroff commented Mar 9, 2020

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.

Still saving lifes! Thank you!

@Curzey
Copy link

@Curzey Curzey commented Apr 5, 2020

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.

This also works for me. Thank you!

@rodrigommv1987
Copy link

@rodrigommv1987 rodrigommv1987 commented Apr 8, 2020

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.

thanks for this!

@tonykimdev
Copy link

@tonykimdev tonykimdev commented Oct 13, 2020

THIS WORKED FOR ME!

npm install webpack@4.40.2

@ChicagoStats
Copy link

@ChicagoStats ChicagoStats commented Dec 14, 2020

THIS WORKED FOR ME!

npm install webpack@4.40.2

Amazing!!!! thanks

@ruvaleev
Copy link

@ruvaleev ruvaleev commented Jan 30, 2021

npm install webpack@4.40.2

Thank you so much!

@HenrijsS

This comment has been minimized.

@saip12
Copy link

@saip12 saip12 commented Mar 31, 2022

Getting below error when Angular version is upgraded.

Module build failed (from ./node_modules/@angular-devkit/build-angular/node_modules/sass-loader/dist/cjs.js):
SassError: Invalid CSS after "...oc-primary: mat": expected expression (e.g. 1px, bold), was ".define-palette($lo"
on line 70 of src/theme.scss

Inside cjs.js File

"use strict";

const loader = require('./index');

module.exports = loader.default;

Tried above solutions and nothing worked so far. Any ideas how to fix it? Thanks!

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

No branches or pull requests