npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents

原创
2018/12/15 09:28
阅读数 3K

场景重现

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

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: 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": "*"
    }
}
展开阅读全文
加载中

作者的其它热门文章

打赏
0
0 收藏
分享
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部