TypeError: loaderContext.getLogger is not a function in utils.js
See original GitHub issueBug 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:
- Created 2 years ago
- Comments:7 (4 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yes, please use
filesystem
cache if you need speed https://webpack.js.org/configuration/cache/#cachetype,thread-loader
only slow your buildsTested on big repos like CRA/next.js/etc and all works fine