详解linux下fsevents模块引起的npm ls报错解决办法
有个项目在mac下开发,安装包npmi,一切正常;
把这个项目放到linux机器上,安装包npmi,报了一堆warning:
npmWARNoptionalSKIPPINGOPTIONALDEPENDENCY:fsevents@^1.2.7(node_modules/chokidar/node_modules/fsevents): npmWARNnotsupSKIPPINGOPTIONALDEPENDENCY:Unsupportedplatformforfsevents@1.2.7:wanted{"os":"darwin","arch":"any"}(current:{"os":"linux","arch":"x64"}) npmWARN0403@1.0.0Nodescription npmWARN0403@1.0.0Norepositoryfield. npmWARNoptionalSKIPPINGOPTIONALDEPENDENCY:abbrev@1.1.1(node_modules/fsevents/node_modules/abbrev): npmWARNenoentSKIPPINGOPTIONALDEPENDENCY:ENOENT:nosuchfileordirectory,rename'/root/2019/0403/node_modules/fsevents/node_modules/abbrev'->'/root/2019/0403/node_modules/fsevents/node_modules/.abbrev.DELETE' npmWARNoptionalSKIPPINGOPTIONALDEPENDENCY:ansi-regex@2.1.1(node_modules/fsevents/node_modules/ansi-regex): npmWARNenoentSKIPPINGOPTIONALDEPENDENCY:ENOENT:nosuchfileordirectory,rename'/root/2019/0403/node_modules/fsevents/node_modules/ansi-regex'->'/root/2019/0403/node_modules/fsevents/node_modules/.ansi-regex.DELETE' npmWARNoptionalSKIPPINGOPTIONALDEPENDENCY:aproba@1.2.0(node_modules/fsevents/node_modules/aproba): npmWARNenoentSKIPPINGOPTIONALDEPENDENCY:ENOENT:nosuchfileordirectory,rename'/root/2019/0403/node_modules/fsevents/node_modules/aproba'->'/root/2019/0403/node_modules/fsevents/node_modules/.aproba.DELETE' npmWARNoptionalSKIPPINGOPTIONALDEPENDENCY:balanced-match@1.0.0(node_modules/fsevents/node_modules/balanced-match): npmWARNenoentSKIPPINGOPTIONALDEPENDENCY:ENOENT:nosuchfileordirectory,rename'/root/2019/0403/node_modules/fsevents/node_modules/balanced-match'->'/root/2019/0403/node_modules/fsevents/node_modules/.balanced-match.DELETE' npmWARNoptionalSKIPPINGOPTIONALDEPENDENCY:chownr@1.1.1(node_modules/fsevents/node_modules/chownr): npmWARNenoentSKIPPINGOPTIONALDEPENDENCY:ENOENT:nosuchfileordirectory,rename'/root/2019/0403/node_modules/fsevents/node_modules/chownr'->'/root/2019/0403/node_modules/fsevents/node_modules/.chownr.DELETE' npmWARNoptionalSKIPPINGOPTIONALDEPENDENCY:code-point-at@1.1.0(node_modules/fsevents/node_modules/code-point-at): npmWARNenoentSKIPPINGOPTIONALDEPENDENCY:ENOENT:nosuchfileordirectory,rename'/root/2019/0403/node_modules/fsevents/node_modules/code-point-at'->'/root/2019/0403/node_modules/fsevents/node_modules/.code-point-at.DELETE' ...
执行npmls,有不少UNMETOPTIONALDEPENDENCY的模块,最后还报了一堆错:
│├──define-property@2.0.2deduped │├──extend-shallow@3.0.2deduped │├──regex-not@1.0.2deduped │└─┬safe-regex@1.1.0 │└──ret@0.1.15 ├─┬UNMETOPTIONALDEPENDENCYfsevents@1.2.7 │├──nan@2.13.2 │└─┬UNMETOPTIONALDEPENDENCYnode-pre-gyp@0.10.3 │├──UNMETOPTIONALDEPENDENCYdetect-libc@1.0.3 │├─┬UNMETDEPENDENCYmkdirp@0.5.1 ││└──UNMETDEPENDENCYminimist@0.0.8 │├─┬UNMETOPTIONALDEPENDENCYneedle@2.2.4 ││├─┬UNMETOPTIONALDEPENDENCYdebug@2.6.9 │││└──UNMETOPTIONALDEPENDENCYms@2.0.0 ││├─┬UNMETOPTIONALDEPENDENCYiconv-lite@0.4.24 │││└──UNMETOPTIONALDEPENDENCYsafer-buffer@2.1.2 ││└──UNMETOPTIONALDEPENDENCYsax@1.2.4 │├─┬UNMETOPTIONALDEPENDENCYnopt@4.0.1 ││├──UNMETOPTIONALDEPENDENCYabbrev@1.1.1 ││└─┬UNMETOPTIONALDEPENDENCYosenv@0.1.5 ││├──UNMETOPTIONALDEPENDENCYos-homedir@1.0.2 ││└──UNMETOPTIONALDEPENDENCYos-tmpdir@1.0.2 │├─┬UNMETOPTIONALDEPENDENCYnpm-packlist@1.2.0 ││├─┬UNMETOPTIONALDEPENDENCYignore-walk@3.0.1 │││└─┬UNMETDEPENDENCYminimatch@3.0.4 │││└─┬UNMETDEPENDENCYbrace-expansion@1.1.11 │││├──UNMETDEPENDENCYbalanced-match@1.0.0 │││└──UNMETDEPENDENCYconcat-map@0.0.1 ││└──UNMETOPTIONALDEPENDENCYnpm-bundled@1.0.5 │├─┬UNMETOPTIONALDEPENDENCYnpmlog@4.1.2 ││├─┬UNMETOPTIONALDEPENDENCYare-we-there-yet@1.1.5 │││├──UNMETOPTIONALDEPENDENCYdelegates@1.0.0 │││└─┬UNMETOPTIONALDEPENDENCYreadable-stream@2.3.6 │││├──UNMETOPTIONALDEPENDENCYcore-util-is@1.0.2 │││├──UNMETDEPENDENCYinherits@2.0.3 │││├──UNMETOPTIONALDEPENDENCYisarray@1.0.0 │││├──UNMETOPTIONALDEPENDENCYprocess-nextick-args@2.0.0 │││├──UNMETDEPENDENCYsafe-buffer@5.1.2 │││├─┬UNMETOPTIONALDEPENDENCYstring_decoder@1.1.1 ││││└──UNMETDEPENDENCYsafe-buffer@5.1.2 │││└──UNMETOPTIONALDEPENDENCYutil-deprecate@1.0.2 ││├──UNMETDEPENDENCYconsole-control-strings@1.1.0 ││├─┬UNMETOPTIONALDEPENDENCYgauge@2.7.4 │││├──UNMETOPTIONALDEPENDENCYaproba@1.2.0 │││├──UNMETDEPENDENCYconsole-control-strings@1.1.0 │││├──UNMETOPTIONALDEPENDENCYhas-unicode@2.0.1 │││├──UNMETOPTIONALDEPENDENCYobject-assign@4.1.1 │││├──UNMETOPTIONALDEPENDENCYsignal-exit@3.0.2 │││├─┬UNMETDEPENDENCYstring-width@1.0.2 ││││├──UNMETDEPENDENCYcode-point-at@1.1.0 ││││├─┬UNMETDEPENDENCYis-fullwidth-code-point@1.0.0 │││││└──UNMETDEPENDENCYnumber-is-nan@1.0.1 ││││└──UNMETDEPENDENCYstrip-ansi@3.0.1 │││├─┬UNMETDEPENDENCYstrip-ansi@3.0.1 ││││└──UNMETDEPENDENCYansi-regex@2.1.1 │││└─┬UNMETOPTIONALDEPENDENCYwide-align@1.1.3 │││└──UNMETDEPENDENCYstring-width@1.0.2 ││└──UNMETOPTIONALDEPENDENCYset-blocking@2.0.0 │├─┬UNMETOPTIONALDEPENDENCYrc@1.2.8 ││├──UNMETOPTIONALDEPENDENCYdeep-extend@0.6.0 ││├──UNMETOPTIONALDEPENDENCYini@1.3.5 ││├──UNMETOPTIONALDEPENDENCYminimist@1.2.0 ││└──UNMETOPTIONALDEPENDENCYstrip-json-comments@2.0.1 │├─┬UNMETOPTIONALDEPENDENCYrimraf@2.6.3 ││└─┬UNMETOPTIONALDEPENDENCYglob@7.1.3 ││├──UNMETOPTIONALDEPENDENCYfs.realpath@1.0.0 ││├─┬UNMETOPTIONALDEPENDENCYinflight@1.0.6 │││├──UNMETDEPENDENCYonce@1.4.0 │││└──UNMETDEPENDENCYwrappy@1.0.2 ││├──UNMETDEPENDENCYinherits@2.0.3 ││├──UNMETDEPENDENCYminimatch@3.0.4 ││├─┬UNMETDEPENDENCYonce@1.4.0 │││└──UNMETDEPENDENCYwrappy@1.0.2 ││└──UNMETOPTIONALDEPENDENCYpath-is-absolute@1.0.1 │├──UNMETOPTIONALDEPENDENCYsemver@5.6.0 │└─┬UNMETOPTIONALDEPENDENCYtar@4.4.8 │├──UNMETOPTIONALDEPENDENCYchownr@1.1.1 │├─┬UNMETOPTIONALDEPENDENCYfs-minipass@1.2.5 ││└──UNMETDEPENDENCYminipass@2.3.5 │├─┬UNMETDEPENDENCYminipass@2.3.5 ││├──UNMETDEPENDENCYsafe-buffer@5.1.2 ││└──UNMETDEPENDENCYyallist@3.0.3 │├─┬UNMETOPTIONALDEPENDENCYminizlib@1.2.1 ││└──UNMETDEPENDENCYminipass@2.3.5 │├──UNMETDEPENDENCYmkdirp@0.5.1 │├──UNMETDEPENDENCYsafe-buffer@5.1.2 │└──UNMETDEPENDENCYyallist@3.0.3 ├─┬glob-parent@3.1.0 │├─┬is-glob@3.1.0 ││└──is-extglob@2.1.1deduped │└──path-dirname@1.0.2 ├──inherits@2.0.3 ├─┬is-binary-path@1.0.1 │└──binary-extensions@1.13.1 ├─┬is-glob@4.0.1 │└──is-extglob@2.1.1 ├──normalize-path@3.0.0 ├──path-is-absolute@1.0.1 ├─┬readdirp@2.2.1 │├──graceful-fs@4.1.15 │├──micromatch@3.1.10deduped │└─┬readable-stream@2.3.6 │├──core-util-is@1.0.2 │├──inherits@2.0.3deduped │├──isarray@1.0.0 │├──process-nextick-args@2.0.0 │├──safe-buffer@5.1.2 │├─┬string_decoder@1.1.1 ││└──safe-buffer@5.1.2deduped │└──util-deprecate@1.0.2 └──upath@1.1.2
npmERR!missing:mkdirp@0.5.1,requiredbynode-pre-gyp@0.10.3 npmERR!missing:minimist@0.0.8,requiredbymkdirp@0.5.1 npmERR!missing:minimatch@3.0.4,requiredbyignore-walk@3.0.1 npmERR!missing:brace-expansion@1.1.11,requiredbyminimatch@3.0.4 npmERR!missing:balanced-match@1.0.0,requiredbybrace-expansion@1.1.11 npmERR!missing:concat-map@0.0.1,requiredbybrace-expansion@1.1.11 npmERR!missing:console-control-strings@1.1.0,requiredbynpmlog@4.1.2 npmERR!missing:inherits@2.0.3,requiredbyreadable-stream@2.3.6 npmERR!missing:safe-buffer@5.1.2,requiredbyreadable-stream@2.3.6 npmERR!missing:safe-buffer@5.1.2,requiredbystring_decoder@1.1.1 npmERR!missing:console-control-strings@1.1.0,requiredbygauge@2.7.4 npmERR!missing:string-width@1.0.2,requiredbygauge@2.7.4 npmERR!missing:strip-ansi@3.0.1,requiredbygauge@2.7.4 npmERR!missing:code-point-at@1.1.0,requiredbystring-width@1.0.2 npmERR!missing:is-fullwidth-code-point@1.0.0,requiredbystring-width@1.0.2 npmERR!missing:strip-ansi@3.0.1,requiredbystring-width@1.0.2 npmERR!missing:number-is-nan@1.0.1,requiredbyis-fullwidth-code-point@1.0.0 npmERR!missing:ansi-regex@2.1.1,requiredbystrip-ansi@3.0.1 npmERR!missing:string-width@1.0.2,requiredbywide-align@1.1.3 npmERR!missing:inherits@2.0.3,requiredbyglob@7.1.3 npmERR!missing:minimatch@3.0.4,requiredbyglob@7.1.3 npmERR!missing:once@1.4.0,requiredbyglob@7.1.3 npmERR!missing:once@1.4.0,requiredbyinflight@1.0.6 npmERR!missing:wrappy@1.0.2,requiredbyinflight@1.0.6 npmERR!missing:wrappy@1.0.2,requiredbyonce@1.4.0 npmERR!missing:minipass@2.3.5,requiredbytar@4.4.8 npmERR!missing:mkdirp@0.5.1,requiredbytar@4.4.8 npmERR!missing:safe-buffer@5.1.2,requiredbytar@4.4.8 npmERR!missing:yallist@3.0.3,requiredbytar@4.4.8 npmERR!missing:minipass@2.3.5,requiredbyfs-minipass@1.2.5 npmERR!missing:safe-buffer@5.1.2,requiredbyminipass@2.3.5 npmERR!missing:yallist@3.0.3,requiredbyminipass@2.3.5 npmERR!missing:minipass@2.3.5,requiredbyminizlib@1.2.1
仔细观察发现UNMETOPTIONALDEPENDENCY的模块和npmERR是同一批模块,也是安装时报warning的那些模块。
再仔细观察发现这些都是fsevents依赖的模块。
fsevents只能在macOS下安装,无法在linux系统安装。linux下会跳过fsevents模块,也不会安装fsevents依赖的模块。
这其实算是npm的一个bug,npmi时报Warn,npmls又报Err,前后不一致,容易有误解。
目前无论用哪个版本的npm都会有这个问题,npmi--no-optional也不能解决这个问题。
这些报错不影响项目的正常运行,因为linux不需要fsevents。
如果不希望看到npmErr,可以用npmi-f强制安装,安装过程没有warn,安装完后npmls看下:
└─┬chokidar@2.1.5 └──fsevents@1.2.7
干净了,没有任何报错。
我的项目是chokidar这个模块依赖了fsevents,chokidar又是browser-sync、webpack等依赖的。
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持毛票票。