服务器之家:专注于VPS、云服务器配置技术及软件下载分享
分类导航

Linux|Centos|Ubuntu|系统进程|Fedora|注册表|Bios|Solaris|Windows7|Windows10|Windows11|windows server|

服务器之家 - 服务器系统 - Linux - 详解linux下fsevents模块引起的npm ls报错解决办法

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

2022-09-01 10:18cp1001 Linux

这篇文章主要介绍了详解linux下fsevents模块引起的npm ls报错解决办法,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧

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

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

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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的模块,最后还报了一堆错:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
│  ├── 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
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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看下:

?
1
2
└─┬ chokidar@2.1.5
└── fsevents@1.2.7

干净了,没有任何报错。

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

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

原文链接:https://segmentfault.com/a/1190000018759308

延伸 · 阅读

精彩推荐
  • Linux使用htaccess规范化网址的配置

    使用htaccess规范化网址的配置

    使用htaccess规范化网址,提高程序的运行效率。...

    Linux教程网7712021-01-31
  • LinuxLinux tar命令使用列子

    Linux tar命令使用列子

    对许多用户来说,在DOS和Windows环境下利用工具软件WinZip、ARJ等压缩或解压文件是比较容易的事。但是,在Linux中如何对文件进行压缩与解压呢? ...

    linux命令大全2792020-06-01
  • Linuxlinux的开发经验详细总结

    linux的开发经验详细总结

    最近换工作了,把平时累积的一些东西发出来,方便带走,根据自己的工作经验增多会不断的更新,感兴趣的朋友可以参考下 ...

    Linux教程网2292019-12-13
  • LinuxLinux容器与Docker的比较

    Linux容器与Docker的比较

    在嵌入式世界中,嵌入式开发人员与云开发人员在不同的需求和约束下工作。大多数嵌入式设备都是固定功能的、单用途的设计,用于很好地执行一件事情...

    粤嵌教育7502021-12-26
  • LinuxLinux删除文件提示Operation not permitted的处理办法

    Linux删除文件提示Operation not permitted的处理办法

    今天小编就为大家分享一篇关于Linux删除文件提示Operation not permitted的处理办法,小编觉得内容挺不错的,现在分享给大家,具有很好的参考价值,需要的朋...

    杰瑞269542022-08-17
  • Linux如何管理和维护RHCS集群

    如何管理和维护RHCS集群

    管理和维护RHCS集群是一个非常复杂和繁琐的工作,要维护好一个RHCS集群,必须熟悉RHCS的基本运行原理,下面小编主要给大家带来的是如何管理和维护RHC...

    脚本之家6172019-06-11
  • LinuxLinux中以sar命令监控系统的使用教程

    Linux中以sar命令监控系统的使用教程

    这篇文章主要介绍了Linux中以sar命令监控系统的使用教程,是Linux入门学习中的基础知识,需要的朋友可以参考下...

    真实的归宿3352019-07-08
  • LinuxLinux下更改主机名(Ubuntu+Redhat)的方法

    Linux下更改主机名(Ubuntu+Redhat)的方法

    今天小编要为大家带来的是Linux下更改主机名(Ubuntu+Redhat)的方法!希望对大家会有帮助!有需要的朋友一起去看看吧...

    脚本之家2282019-06-05