question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: loaderContext.getLogger is not a function in utils.js

See original GitHub issue

Bug report

Actual Behavior

Installed sass-loader 12.3.0 and running webpack 5 to compile a sass file using the dart-sass(js) implementation got this. Does not happen in earlier versions.

TypeError: loaderContext.getLogger is not a function
    at getSassOptions (***/node_modules/sass-loader/dist/utils.js:209:34)
    at Object.loader (***/node_modules/sass-loader/dist/index.js:35:55)
    at LOADER_EXECUTION (***/node_modules/loader-runner/lib/LoaderRunner.js:132:14)
    at runSyncOrAsync (***/node_modules/loader-runner/lib/LoaderRunner.js:133:4)
    at iterateNormalLoaders (***/node_modules/loader-runner/lib/LoaderRunner.js:250:2)
    at ***/node_modules/loader-runner/lib/LoaderRunner.js:223:4
    at FSReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read_file_context:68:3)
***/node_modules/sass-loader/dist/utils.js:209
    const logger = loaderContext.getLogger("sass-loader");

versions

        "css-loader": "5.2.4",
        "sass": "1.32.5",
        "sass-loader": "^12.3.0",
        "webpack": "5.51.1",

Expected Behavior

I haven’t done a full code trace of where the loaderContext variable is created, but it doesn’t seem to have a method called getLogger at all. If I search for getLogger calls in the codebase, I usually find it used as a method of a Compilation instance.

How Do We Reproduce?

If there isn’t something obvious about this error and you aren’t able to recreate, I can set up a repo as an example. I’m filing this issue just to see if there is something clearly wrong in the new release.

Please paste the results of npx webpack-cli info here, and mention other relevant information

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
alexander-akaitcommented, Oct 28, 2021

Yes, please use filesystem cache if you need speed https://webpack.js.org/configuration/cache/#cachetype, thread-loader only slow your builds

1reaction
alexander-akaitcommented, Oct 28, 2021

Tested on big repos like CRA/next.js/etc and all works fine

Read more comments on GitHub >

github_iconTop Results From Across the Web

webpack ts-loader error : loaderContext.getOptions is not a ...
node_modules/ts-loader/index.js): TypeError: loaderContext.getOptions is not a function at getLoaderOptions ... webpack.config.js file :
Read more >
UnhandledPromiseRejectionWar...
UnhandledPromiseRejectionWarning: TypeError: loaderContext.getLogger is not a function #135 ... sass-loader/dist/utils.js.
Read more >
Loader Interface - webpack
A loader is a JavaScript module that exports a function. The loader runner calls this function and passes the result of the previous...
Read more >
loader-utils - npm
Parses a passed string (e.g. loaderContext.resourceQuery ) as a query string, and returns an object. const params = loaderUtils.
Read more >
loaderContext.emitError is not a function 这个是什么问题啊 ...
慕课网为用户解答loaderContext.emitError is not a function 这个是什么问题啊各位亲人cry,TypeError: loaderCon.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found