TypeError: this.getOptions is not a function
yelvert opened this issue Β· 19 comments
Module build failed (from ./node_modules/style-loader/dist/cjs.js):
TypeError: this.getOptions is not a function
at Object.loader (.../node_modules/style-loader/dist/index.js:18:24)
It looks like #501 dropped loader-utils as a dependency where this function came from, and instead tries to call this.getOptions which doesnt exist.
npm i style-loader@2.0.0 -D
You need webpack v5 to use the latest version of style-loader, please read changelog
I'm getting this error when using Webpack 5.59.1 and the latest version of style-loader. Do I still need to downgrade to style-loader@2? (Also happens with Webpack 5 and style-loader 2.)
Run npm ls style-loader
Gives the return style-loader@3.3.1
.
Do you have thread-loader
?
Nope.
Downgrading Webpack to 4 and style-loader to 2 resolves it. (I write βresolves itβ but it's obviously not a solution.)
Run npm ls webpack
when you try to upgrade to webpack v5
βββ¬ @wordpress/dependency-extraction-webpack-plugin@3.1.4
β βββ¬ webpack@5.39.1
β βββ¬ terser-webpack-plugin@5.1.3
β βββ webpack@5.39.1 deduped
βββ¬ babel-loader@8.2.2
β βββ webpack@5.39.1 deduped
βββ¬ css-loader@5.2.6
β βββ webpack@5.39.1 deduped
βββ¬ style-loader@2.0.0
β βββ webpack@5.39.1 deduped
βββ¬ svg-url-loader@7.1.1
β βββ¬ file-loader@6.2.0
β β βββ webpack@5.39.1 deduped
β βββ webpack@5.39.1 deduped
βββ¬ webpack-stream@6.1.2
βββ¬ webpack@4.46.0
βββ¬ terser-webpack-plugin@1.4.5
βββ webpack@4.46.0 deduped
Problem in webpack-stream
, as you can see it install webpack v4...
...and with style-loader@3
:
βββ¬ @wordpress/dependency-extraction-webpack-plugin@3.1.4
β βββ¬ webpack@5.39.1
β βββ¬ terser-webpack-plugin@5.1.3
β βββ webpack@5.39.1 deduped
βββ¬ babel-loader@8.2.2
β βββ webpack@5.39.1 deduped
βββ¬ css-loader@5.2.6
β βββ webpack@5.39.1 deduped
βββ¬ style-loader@3.3.1
β βββ webpack@5.39.1 deduped
βββ¬ svg-url-loader@7.1.1
β βββ¬ file-loader@6.2.0
β β βββ webpack@5.39.1 deduped
β βββ webpack@5.39.1 deduped
βββ¬ webpack-stream@6.1.2
βββ¬ webpack@4.46.0
βββ¬ terser-webpack-plugin@1.4.5
βββ webpack@4.46.0 deduped
Update webpack-stream
to v7
Bingo. Perfect. Thanks!
You need webpack v5 to use the latest version of style-loader, please read changelog
Thanks man, it helped me a lot! <3
./src/index.css
TypeError: this.getOptions is not a function
i m getting this error while executing please help me out
I am also getting the issue above. how to solve issue?
take your laptop and throw it into the ocean.
seriously though, i have the same problem.
Have you read the comments above which show the solution?
ERROR in ./app/javascript/stylesheets/application.scss (./node_modules/css-loader/dist/cjs.js??ref--6-1!./node_modules/postcss-loader/dist/cjs.js??ref--6-2!./node_modules/sass-loader/dist/cjs.js??ref--6-3!./app/javascript/stylesheets/application.scss)
Module build failed (from ./node_modules/postcss-loader/dist/cjs.js):
TypeError: this.getOptions is not a function
at Object.loader (/home/yash/Desktop/rails_project/granite/node_modules/postcss-loader/dist/index.js:28:24)