Less is used in vue-CLI generation projects, and less and less-loader are manually installed according to the vue-CLI help

# Less
npm install -D less-loader less
Copy the code

After installation, write less style in vue plug-in, compile error

Then write the following test code:

Error:

error in ./src/components/Button/Button.vue? vue&type=style&index=0&id=4439b54f&lang=less&scoped=true& Syntax Error: TypeError: this.getOptions is not a function

It is found that the version of less-Loader is too high. The webPack of the vue-CLI version installed is [email protected], while the version of less-Loader installed is 8.0. The 8.0 version requires at least 5.0 WebPack, as follows:

Later, less-Loader is downgraded to 7.3. The problem is resolved

Uninstall NPM uninstall less-loader of earlier versions

Install the lower version NPM install [email protected]