详解linux下fsevents模块引起的npm ls报错解决办法

有个项目在mac下开发,安装包npm i,一切正常;

把这个项目放到linux机器上,安装包npm i,报了一堆warning:

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.7: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN 0403@1.0.0 No description
npm WARN 0403@1.0.0 No repository field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: abbrev@1.1.1 (node_modules/fsevents/node_modules/abbrev):
npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, rename '/root/2019/0403/node_modules/fsevents/node_modules/abbrev' -> '/root/2019/0403/node_modules/fsevents/node_modules/.abbrev.DELETE'
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: ansi-regex@2.1.1 (node_modules/fsevents/node_modules/ansi-regex):
npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, rename '/root/2019/0403/node_modules/fsevents/node_modules/ansi-regex' -> '/root/2019/0403/node_modules/fsevents/node_modules/.ansi-regex.DELETE'
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: aproba@1.2.0 (node_modules/fsevents/node_modules/aproba):
npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, rename '/root/2019/0403/node_modules/fsevents/node_modules/aproba' -> '/root/2019/0403/node_modules/fsevents/node_modules/.aproba.DELETE'
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: balanced-match@1.0.0 (node_modules/fsevents/node_modules/balanced-match):
npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, rename '/root/2019/0403/node_modules/fsevents/node_modules/balanced-match' -> '/root/2019/0403/node_modules/fsevents/node_modules/.balanced-match.DELETE'
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: chownr@1.1.1 (node_modules/fsevents/node_modules/chownr):
npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, rename '/root/2019/0403/node_modules/fsevents/node_modules/chownr' -> '/root/2019/0403/node_modules/fsevents/node_modules/.chownr.DELETE'
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: code-point-at@1.1.0 (node_modules/fsevents/node_modules/code-point-at):
npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, rename '/root/2019/0403/node_modules/fsevents/node_modules/code-point-at' -> '/root/2019/0403/node_modules/fsevents/node_modules/.code-point-at.DELETE'
...

执行npm ls,有不少UNMET OPTIONAL DEPENDENCY的模块,最后还报了一堆错:

│  ├── define-property@2.0.2 deduped
│  ├── extend-shallow@3.0.2 deduped
│  ├── regex-not@1.0.2 deduped
│  └─┬ safe-regex@1.1.0
│   └── ret@0.1.15
├─┬ UNMET OPTIONAL DEPENDENCY fsevents@1.2.7
│ ├── nan@2.13.2
│ └─┬ UNMET OPTIONAL DEPENDENCY node-pre-gyp@0.10.3
│  ├── UNMET OPTIONAL DEPENDENCY detect-libc@1.0.3
│  ├─┬ UNMET DEPENDENCY mkdirp@0.5.1
│  │ └── UNMET DEPENDENCY minimist@0.0.8
│  ├─┬ UNMET OPTIONAL DEPENDENCY needle@2.2.4
│  │ ├─┬ UNMET OPTIONAL DEPENDENCY debug@2.6.9
│  │ │ └── UNMET OPTIONAL DEPENDENCY ms@2.0.0
│  │ ├─┬ UNMET OPTIONAL DEPENDENCY iconv-lite@0.4.24
│  │ │ └── UNMET OPTIONAL DEPENDENCY safer-buffer@2.1.2
│  │ └── UNMET OPTIONAL DEPENDENCY sax@1.2.4
│  ├─┬ UNMET OPTIONAL DEPENDENCY nopt@4.0.1
│  │ ├── UNMET OPTIONAL DEPENDENCY abbrev@1.1.1
│  │ └─┬ UNMET OPTIONAL DEPENDENCY osenv@0.1.5
│  │  ├── UNMET OPTIONAL DEPENDENCY os-homedir@1.0.2
│  │  └── UNMET OPTIONAL DEPENDENCY os-tmpdir@1.0.2
│  ├─┬ UNMET OPTIONAL DEPENDENCY npm-packlist@1.2.0
│  │ ├─┬ UNMET OPTIONAL DEPENDENCY ignore-walk@3.0.1
│  │ │ └─┬ UNMET DEPENDENCY minimatch@3.0.4
│  │ │  └─┬ UNMET DEPENDENCY brace-expansion@1.1.11
│  │ │   ├── UNMET DEPENDENCY balanced-match@1.0.0
│  │ │   └── UNMET DEPENDENCY concat-map@0.0.1
│  │ └── UNMET OPTIONAL DEPENDENCY npm-bundled@1.0.5
│  ├─┬ UNMET OPTIONAL DEPENDENCY npmlog@4.1.2
│  │ ├─┬ UNMET OPTIONAL DEPENDENCY are-we-there-yet@1.1.5
│  │ │ ├── UNMET OPTIONAL DEPENDENCY delegates@1.0.0
│  │ │ └─┬ UNMET OPTIONAL DEPENDENCY readable-stream@2.3.6
│  │ │  ├── UNMET OPTIONAL DEPENDENCY core-util-is@1.0.2
│  │ │  ├── UNMET DEPENDENCY inherits@2.0.3
│  │ │  ├── UNMET OPTIONAL DEPENDENCY isarray@1.0.0
│  │ │  ├── UNMET OPTIONAL DEPENDENCY process-nextick-args@2.0.0
│  │ │  ├── UNMET DEPENDENCY safe-buffer@5.1.2
│  │ │  ├─┬ UNMET OPTIONAL DEPENDENCY string_decoder@1.1.1
│  │ │  │ └── UNMET DEPENDENCY safe-buffer@5.1.2
│  │ │  └── UNMET OPTIONAL DEPENDENCY util-deprecate@1.0.2
│  │ ├── UNMET DEPENDENCY console-control-strings@1.1.0
│  │ ├─┬ UNMET OPTIONAL DEPENDENCY gauge@2.7.4
│  │ │ ├── UNMET OPTIONAL DEPENDENCY aproba@1.2.0
│  │ │ ├── UNMET DEPENDENCY console-control-strings@1.1.0
│  │ │ ├── UNMET OPTIONAL DEPENDENCY has-unicode@2.0.1
│  │ │ ├── UNMET OPTIONAL DEPENDENCY object-assign@4.1.1
│  │ │ ├── UNMET OPTIONAL DEPENDENCY signal-exit@3.0.2
│  │ │ ├─┬ UNMET DEPENDENCY string-width@1.0.2
│  │ │ │ ├── UNMET DEPENDENCY code-point-at@1.1.0
│  │ │ │ ├─┬ UNMET DEPENDENCY is-fullwidth-code-point@1.0.0
│  │ │ │ │ └── UNMET DEPENDENCY number-is-nan@1.0.1
│  │ │ │ └── UNMET DEPENDENCY strip-ansi@3.0.1
│  │ │ ├─┬ UNMET DEPENDENCY strip-ansi@3.0.1
│  │ │ │ └── UNMET DEPENDENCY ansi-regex@2.1.1
│  │ │ └─┬ UNMET OPTIONAL DEPENDENCY wide-align@1.1.3
│  │ │  └── UNMET DEPENDENCY string-width@1.0.2
│  │ └── UNMET OPTIONAL DEPENDENCY set-blocking@2.0.0
│  ├─┬ UNMET OPTIONAL DEPENDENCY rc@1.2.8
│  │ ├── UNMET OPTIONAL DEPENDENCY deep-extend@0.6.0
│  │ ├── UNMET OPTIONAL DEPENDENCY ini@1.3.5
│  │ ├── UNMET OPTIONAL DEPENDENCY minimist@1.2.0
│  │ └── UNMET OPTIONAL DEPENDENCY strip-json-comments@2.0.1
│  ├─┬ UNMET OPTIONAL DEPENDENCY rimraf@2.6.3
│  │ └─┬ UNMET OPTIONAL DEPENDENCY glob@7.1.3
│  │  ├── UNMET OPTIONAL DEPENDENCY fs.realpath@1.0.0
│  │  ├─┬ UNMET OPTIONAL DEPENDENCY inflight@1.0.6
│  │  │ ├── UNMET DEPENDENCY once@1.4.0
│  │  │ └── UNMET DEPENDENCY wrappy@1.0.2
│  │  ├── UNMET DEPENDENCY inherits@2.0.3
│  │  ├── UNMET DEPENDENCY minimatch@3.0.4
│  │  ├─┬ UNMET DEPENDENCY once@1.4.0
│  │  │ └── UNMET DEPENDENCY wrappy@1.0.2
│  │  └── UNMET OPTIONAL DEPENDENCY path-is-absolute@1.0.1
│  ├── UNMET OPTIONAL DEPENDENCY semver@5.6.0
│  └─┬ UNMET OPTIONAL DEPENDENCY tar@4.4.8
│   ├── UNMET OPTIONAL DEPENDENCY chownr@1.1.1
│   ├─┬ UNMET OPTIONAL DEPENDENCY fs-minipass@1.2.5
│   │ └── UNMET DEPENDENCY minipass@2.3.5
│   ├─┬ UNMET DEPENDENCY minipass@2.3.5
│   │ ├── UNMET DEPENDENCY safe-buffer@5.1.2
│   │ └── UNMET DEPENDENCY yallist@3.0.3
│   ├─┬ UNMET OPTIONAL DEPENDENCY minizlib@1.2.1
│   │ └── UNMET DEPENDENCY minipass@2.3.5
│   ├── UNMET DEPENDENCY mkdirp@0.5.1
│   ├── UNMET DEPENDENCY safe-buffer@5.1.2
│   └── UNMET DEPENDENCY yallist@3.0.3
├─┬ glob-parent@3.1.0
│ ├─┬ is-glob@3.1.0
│ │ └── is-extglob@2.1.1 deduped
│ └── 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.10 deduped
│ └─┬ readable-stream@2.3.6
│  ├── core-util-is@1.0.2
│  ├── inherits@2.0.3 deduped
│  ├── isarray@1.0.0
│  ├── process-nextick-args@2.0.0
│  ├── safe-buffer@5.1.2
│  ├─┬ string_decoder@1.1.1
│  │ └── safe-buffer@5.1.2 deduped
│  └── util-deprecate@1.0.2
└── upath@1.1.2
npm ERR! missing: mkdirp@0.5.1, required by node-pre-gyp@0.10.3
npm ERR! missing: minimist@0.0.8, required by mkdirp@0.5.1
npm ERR! missing: minimatch@3.0.4, required by ignore-walk@3.0.1
npm ERR! missing: brace-expansion@1.1.11, required by minimatch@3.0.4
npm ERR! missing: balanced-match@1.0.0, required by brace-expansion@1.1.11
npm ERR! missing: concat-map@0.0.1, required by brace-expansion@1.1.11
npm ERR! missing: console-control-strings@1.1.0, required by npmlog@4.1.2
npm ERR! missing: inherits@2.0.3, required by readable-stream@2.3.6
npm ERR! missing: safe-buffer@5.1.2, required by readable-stream@2.3.6
npm ERR! missing: safe-buffer@5.1.2, required by string_decoder@1.1.1
npm ERR! missing: console-control-strings@1.1.0, required by gauge@2.7.4
npm ERR! missing: string-width@1.0.2, required by gauge@2.7.4
npm ERR! missing: strip-ansi@3.0.1, required by gauge@2.7.4
npm ERR! missing: code-point-at@1.1.0, required by string-width@1.0.2
npm ERR! missing: is-fullwidth-code-point@1.0.0, required by string-width@1.0.2
npm ERR! missing: strip-ansi@3.0.1, required by string-width@1.0.2
npm ERR! missing: number-is-nan@1.0.1, required by is-fullwidth-code-point@1.0.0
npm ERR! missing: ansi-regex@2.1.1, required by strip-ansi@3.0.1
npm ERR! missing: string-width@1.0.2, required by wide-align@1.1.3
npm ERR! missing: inherits@2.0.3, required by glob@7.1.3
npm ERR! missing: minimatch@3.0.4, required by glob@7.1.3
npm ERR! missing: once@1.4.0, required by glob@7.1.3
npm ERR! missing: once@1.4.0, required by inflight@1.0.6
npm ERR! missing: wrappy@1.0.2, required by inflight@1.0.6
npm ERR! missing: wrappy@1.0.2, required by once@1.4.0
npm ERR! missing: minipass@2.3.5, required by tar@4.4.8
npm ERR! missing: mkdirp@0.5.1, required by tar@4.4.8
npm ERR! missing: safe-buffer@5.1.2, required by tar@4.4.8
npm ERR! missing: yallist@3.0.3, required by tar@4.4.8
npm ERR! missing: minipass@2.3.5, required by fs-minipass@1.2.5
npm ERR! missing: safe-buffer@5.1.2, required by minipass@2.3.5
npm ERR! missing: yallist@3.0.3, required by minipass@2.3.5
npm ERR! missing: minipass@2.3.5, required by minizlib@1.2.1

仔细观察发现UNMET OPTIONAL DEPENDENCY的模块和npm ERR是同一批模块,也是安装时报warning的那些模块。

再仔细观察发现这些都是fsevents依赖的模块。

fsevents只能在macOS下安装,无法在linux系统安装。linux下会跳过fsevents模块,也不会安装fsevents依赖的模块。

这其实算是npm的一个bug,npm i时报Warn,npm ls又报Err,前后不一致,容易有误解。

目前无论用哪个版本的npm都会有这个问题,npm i --no-optional也不能解决这个问题。

这些报错不影响项目的正常运行,因为linux不需要fsevents。

如果不希望看到npm Err,可以用npm i -f强制安装,安装过程没有warn,安装完后npm ls看下:

└─┬ chokidar@2.1.5
└── fsevents@1.2.7

干净了,没有任何报错。

我的项目是chokidar这个模块依赖了fsevents,chokidar又是browser-sync、webpack等依赖的。

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持我们。

(0)

相关推荐

  • 详解linux系统输入输出管理和vim的常用功能

    ####系统中输入输出的管理#### 1.理解系统的输入输出重定向 输入重定向是指把文件导入到命令中,而输出重定向则是把原本要输出到屏幕的数据信息写入到指定文件中. 2.管理输入输出的符号 ##输出重定向 >       ##重定向正确输    2>       ##重定向错误输出    &>       ##重定向所有输出 注意: 重定向会覆盖原文件内容 >>     ##不会覆盖原文件内容    2>>     ##错误输出,不覆盖    &&

  • linux中alarm函数的实例讲解

    linux alarm函数简介 上代码: #include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <signal.h> int main(int argc, char *argv[]) { alarm(5); sleep(20); printf("end!\n"); return 0; } 运行5秒后,内核向进程发出SIGALRM信息,进程被终止,所以上述程序

  • linux shell中if的各种判断

    shell编程中使用到得if语句内判断参数 –b当file存在并且是块文件时返回真 -c当file存在并且是字符文件时返回真 -d当pathname存在并且是一个目录时返回真 -e当pathname指定的文件或目录存在时返回真 -f当file存在并且是正规文件时返回真 -g当由pathname指定的文件或目录存在并且设置了SGID位时返回为真 -h当file存在并且是符号链接文件时返回真,该选项在一些老系统上无效 -k当由pathname指定的文件或目录存在并且设置了"粘滞"位时返回真

  • linux下搭建go环境的安装配置讲解

    linux下搭建go环境很简单: 1.下载go1.2.1.linux-386.tar.gz,网上到处有类似包,并放到linux目录下. taogeqq@taogeqq-virtual-machine:~/myspace$ ls a.out go1.2.1.linux-386.tar.gz test.cpp test.go taogeqq@taogeqq-virtual-machine:~/myspace$ 2.  切换到root用户,在root下解压,解压即安装,多么绿色的软件啊: root@t

  • linux下查看so或可执行程序的依赖库

    在linux下查看so或可执行程序的依赖库 Linux下可执行程序包括可执行程序exe和so, 两者文件都是ELF打头的. objdump -x libxxxxx.so | grep NEEDED objdump -x 可执行程序名 | grep NEEDED 或 arm-hisiv300-linux-objdump -x 可执行程序 | grep NEEDED arm-hisiv300-linux-readelf -a 可执行程序 | grep NEEDED linux之如何查看哪些进程在使用

  • linux的cut命令用法总结

    要用到,来mark一下: ubuntu@VM-0-15-ubuntu:~/taoge$ cat b.txt abc abcd ubuntu@VM-0-15-ubuntu:~/taoge$ cat b.txt | cut -c 1 a a ubuntu@VM-0-15-ubuntu:~/taoge$ cat b.txt | cut -c 2 b b ubuntu@VM-0-15-ubuntu:~/taoge$ cat b.txt | cut -c 1-2 ab ab ubuntu@VM-0-15-

  • 在linux下玩转带有超时时间的connect函数

    在之前的文章中,我们在Windows下玩过带有超时时间的,本文我们在linux下来玩.在某次面试中,还被遇到了这个问题,有意思. 直接上客户端代码: #include <unistd.h> #include <sys/types.h> #include <sys/socket.h> #include <netdb.h> #include <stdio.h> #include <stdlib.h> #include <string

  • linux shell之控制台打印各种颜色字体和背景的实现方法

    1 问题 控制台打印各种颜色字体和背景 字体颜色 #30:黑 #31:红 #32:绿 #33:黄 #34:蓝色 #35:紫色 #36:深绿 #37:白色 背景颜色 #40:黑 #41:深红 #42:绿 #43:黄色 #44:蓝色 #45:紫色 #46:深绿 #47:白色 echo -e "\e[43;35m chenyu\e[0m hello word" 比如上面的命令,43是背景颜色,35是字体颜色, \e[0m 是还原本色 2 代码实现 这里写的是color.sh文件如下 #!/b

  • linux shell之pushd、popd和dirs的使用讲解

    1 问题 我们有时候需要保存多个路径,上下键切换不方便,用cd-只能到上个目录,我们可以用dirs和pushd和popd 2 dirs.pushd.popd dirs: 这个命令显示栈里面所有的路径,一定会包含当前路径,常用参数如下 dirs -v 显示栈里面的所有路径和下标,通过下标,我们可以用pushd +下标到这个目录,然后popd+下标把这个路径在栈里面弹出来, dirs -c 清除栈里所有路径,但是当前路径不会删除 pushd:我们可以添加目录到栈(dirs)里面,比如添加当前目录pu

  • linux shell之通过标识测试文件系统属性的方法示例

    1 通过标识测试文件系统属性 [ -f $file_var ] :如果给定的变量包含正常的文件路径或文件名,则返回真. [ -x $var ] :如果给定的变量包含的文件可执行,则返回真. [ -d $var ] :如果给定的变量包含的是目录,则返回真. [ -e $var ] :如果给定的变量包含的文件存在,则返回真. [ -c $var ] :如果给定的变量包含的是一个字符设备文件的路径,则返回真. [ -b $var ] :如果给定的变量包含的是一个块设备文件的路径,则返回真. [ -w

随机推荐