Webpack packaging error TypeError: this.getOptions is not a function at Object.lessLoader

In the past two days, I re-learned the use of Webpack. When learning to package css/less style resources, an error occurred:

 

The key error message is: this.getOptions is not a function. After a look at Baidu on the Internet, it is a version problem.

Then I checked the npm official website again, and it turned out that less-loader released a new version of 8.0.0 22 days ago, which is likely to be a compatibility issue caused by the new version.

 

Solution: Uninstall less-loader and download a lower version again so that it can be packaged normally.

cnpm uninstall less-loader
cnpm i -D less-loader@7 // The latest version is 8.0.0, so re-download the latest version of version 7

Read More: