更新下 使用yarn貌似會幫助跳過這個問題:
info fsevents@2.1.2: The platform "win32" is incompatible with this module.
info "fsevents@2.1.2" is an optional dependency and failed compatibility check. Excluding it from installation.
info fsevents@1.2.9: The platform "win32" is incompatible with this module.
info "fsevents@1.2.9" is an optional dependency and failed compatibility check. Excluding it from installation.
===
有需要下載了一個模板項目,安裝ui部分失敗,提示:
npm WARN deprecated fsevents@1.2.9: One of your dependencies needs to upgrade to fsevents v2: 1) Proper nodejs v10+ support 2) No more fetch
ing binaries from AWS, smaller package size
npm ERR! Unexpected end of JSON input while parsing near '...LNCxGNsOAHRWRMGoXrtcI'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\user\AppData\Roaming\npm-cache\_logs\2019-12-06T07_31_31_687Z-debug.log
單獨提出來安裝:
$ npm install fsevents
npm ERR! code EBADPLATFORM
npm ERR! notsup Unsupported platform for fsevents@2.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm ERR! notsup Valid OS: darwin
npm ERR! notsup Valid Arch: any
npm ERR! notsup Actual OS: win32
npm ERR! notsup Actual Arch: x64
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\neoliu6\AppData\Roaming\npm-cache\_logs\2019-12-06T07_33_23_843Z-debug.log
原因明了了,這個包是在mac系統中的,windows沒有。查了下資料,大概是windows也不需要,不用安裝。
解決方法是,把fsevents依賴放到可選依賴中:
vi package.json
"optionalDependencies": { "fsevents": "*" }
重新執行安裝(有個坑,需要刪除package_lock.json,否則標記會失效,所有依賴都將被安裝):
npm install --no-optional
參考資料:
https://stackoverflow.com/questions/41570364/npm-install-not-working-in-windows#
But it says it is optional so I ran $npm install --no-optional and that error went away but I still can't install.
https://github.com/npm/npm/issues/17633
I'm seeing this today with npm 5.3.0.
npm install --no-optional
works IIF a package-lock.json does not exist. If the package-lock.json file exists, then the flag is ignored and all dependencies get installed.