npm ERR! How to install compiler-sfc that meets peer dependency with [email protected]?

1.2k Views Asked by At

My packageJSON

"devDependencies": {
        "@fortawesome/fontawesome-svg-core": "^1.2.35",
        "@fortawesome/free-solid-svg-icons": "^5.15.3",
        "@vue/compiler-sfc": "^3.0.11",
        "axios": "^0.21",
        "bootstrap": "^4.0.0",
        "install": "^0.13.0",
        "jquery": "^3.2",
        "laravel-mix": "^6.0.19",
        "lodash": "^4.17.19",
        "popper.js": "^1.12",
        "postcss": "^8.3.0",
        "resolve-url-loader": "^3.1.3",
        "sass": "^1.34.1",
        "sass-loader": "^8.0.0",
        "vue": "^2.6.14",
        "vue-izitoast": "^1.2.1",
        "vue-loader": "^15.9.5",
        "vue-template-compiler": "^2.6.14"
    }

When I check the npm list vue

`-- UNMET PEER DEPENDENCY [email protected]

npm ERR! peer dep missing: [email protected], required by @vue/[email protected]

How to install compiler-sfc that meets peer dependency with [email protected]? I don't want to update vue to 3.

1

There are 1 best solutions below

2
On

This sounds a little bit like an XY Problem, because the @vue/compiler-sfc package was created for use with Vue 3, and like the error says, has Vue 3 as a peer dependency.

This means it's incompatible with Vue 2, so you can't use it without upgrading to Vue 3.

The bigger question is– why do you think you need this package?
@vue/compiler-sfc is a pack of "lower level utilities for compiling Vue Single File Components":

This package contains lower level utilities that you can use if you are writing a plugin / transform for a bundler or module system that compiles Vue Single File Components (SFCs) into JavaScript. It is used in vue-loader, rollup-plugin-vue and vite.

Based on your given package list, I don't think you're writing a bundler or module system, so my advice would be to just ditch this dependency.