欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents

程序员文章站 2022-05-29 23:46:41
...

场景重现

npm install --verbose 安装依赖的时,出现如下警告

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm verb notsup SKIPPING OPTIONAL DEPENDENCY: Valid OS:    darwin
npm verb notsup SKIPPING OPTIONAL DEPENDENCY: Valid Arch:  any
npm verb notsup SKIPPING OPTIONAL DEPENDENCY: Actual OS:   win32
npm verb notsup SKIPPING OPTIONAL DEPENDENCY: Actual Arch: x64

释疑

这不是什么真的有问题,只是你的某些包依赖fsevents包,而fsevents包是MacOS系统下,在Windows/Linux下会提示警告,但不会安装.

解决办法

但是强迫症患者表示不能接受,换个角度看释疑,意味着fsevents在MacOS下是必须的,而在Windows/Linux下是可选的.

那么我们可以通过package.jsonoptionalDependencies来规避警告,然后npm install --no-optional --verbose不安装可选项即可.

参考如下:

{
    "dependencies": {
        "axios": "^0.18.0",
        "echarts": "^4.2.0-rc.2",
        "element-ui": "^2.4.11",
        "screenfull": "^3.3.3",
        "vue": "^2.5.17",
        "vue-router": "^3.0.1",
        "vuex": "^3.0.1"
    },
    "devDependencies": {
        "@vue/cli-plugin-babel": "^3.0.5",
        "@vue/cli-service": "^3.0.5",
        "less": "^3.0.4",
        "less-loader": "^4.1.0",
        "vue-template-compiler": "^2.5.17"
    },
    "optionalDependencies": {
        "fsevents": "*"
    }
}

转载于:https://my.oschina.net/taadis/blog/2988809