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

TypeError: this.getOptions is not a function #517

Closed
yelvert opened this issue Jul 1, 2021 · 20 comments
Closed

TypeError: this.getOptions is not a function #517

yelvert opened this issue Jul 1, 2021 · 20 comments

Comments

@yelvert
Copy link

yelvert commented Jul 1, 2021

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.

@milu2003
Copy link

milu2003 commented Jul 1, 2021

npm i style-loader@2.0.0 -D

@alexander-akait
Copy link
Member

You need webpack v5 to use the latest version of style-loader, please read changelog

@markhowellsmead
Copy link

markhowellsmead commented Oct 25, 2021

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.)

@alexander-akait
Copy link
Member

Run npm ls style-loader

@markhowellsmead
Copy link

markhowellsmead commented Oct 25, 2021

Gives the return style-loader@3.3.1.

@alexander-akait
Copy link
Member

Do you have thread-loader?

@markhowellsmead
Copy link

Nope.

@markhowellsmead
Copy link

markhowellsmead commented Oct 25, 2021

Downgrading Webpack to 4 and style-loader to 2 resolves it. (I write “resolves it” but it's obviously not a solution.)

@alexander-akait
Copy link
Member

Run npm ls webpack when you try to upgrade to webpack v5

@markhowellsmead
Copy link

├─┬ @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

@alexander-akait
Copy link
Member

Problem in webpack-stream, as you can see it install webpack v4...

@markhowellsmead
Copy link

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

@alexander-akait
Copy link
Member

Update webpack-stream to v7

@markhowellsmead
Copy link

Bingo. Perfect. Thanks!

@GustavoPintod
Copy link

You need webpack v5 to use the latest version of style-loader, please read changelog

Thanks man, it helped me a lot! <3

spaceo added a commit to reload/dpl-react that referenced this issue May 6, 2022
Without style-loader
because it needs to be updated together with webpack.
webpack-contrib/style-loader#517
@manoharmaddi
Copy link

./src/index.css
TypeError: this.getOptions is not a function

i m getting this error while executing please help me out

@dep
Copy link

dep commented Jan 12, 2023

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.

@markhowellsmead
Copy link

Have you read the comments above which show the solution?

@yash4882
Copy link

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)

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

9 participants