如何解决在非MAC OS上进行npm install抛出fsevents警告的问题?


115

npm install命令上发出以下警告-

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.2 (node_modules\rea
ct-scripts\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@
1.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"}
)
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules\ch
okidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@
1.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"}
)

该警告显然导致我们的Jenkins Job标记为失败,因此我们只是在尝试摆脱相同的警告。

我已经检查了这个https://stackoverflow.com/a/42938398/351903 但是,与那里提到的不同,我的设置中没有任何/ node_modules / fserrors。另外,我的package.json不包含fserrors。以下是我的package.json-

{
  "name": "mvc-panel",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "bootstrap": "^3.3.7",
    "jquery": "^3.2.1",
    "material-ui": "^0.18.3",
    "qs": "^6.4.0",
    "react": "^15.5.4",
    "react-alert": "^2.1.2",
    "react-bootstrap-table": "^3.4.1",
    "react-dom": "^15.5.4",
    "react-loader": "^2.4.2",
    "react-router-dom": "^4.1.1",
    "react-tap-event-plugin": "^2.0.1",
    "serve": "^6.0.0"
  },
  "devDependencies": {
    "datatables.net": "^1.10.15",
    "jquery": "^3.2.1",
    "react-scripts": "^1.0.7"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  }
}

我可以在node_modules\react-scripts\package.json-

{
  "_args": [
    [
      {
        "raw": "react-scripts@^1.0.7",
        "scope": null,
        "escapedName": "react-scripts",
        "name": "react-scripts",
        "rawSpec": "^1.0.7",
        "spec": ">=1.0.7 <2.0.0",
        "type": "range"
      },
      "D:\\Sandeepan\\Payu MVC\\backend codebase\\MVC2.0\\panel\\mvc-panel"
    ]
  ],
  "_from": "react-scripts@>=1.0.7 <2.0.0",
  "_id": "react-scripts@1.0.14",
  "_inCache": true,
  "_location": "/react-scripts",
  "_nodeVersion": "8.5.0",
  "_npmOperationalInternal": {
    "host": "s3://npm-registry-packages",
    "tmp": "tmp/react-scripts-1.0.14.tgz_1506471610836_0.5613740666303784"
  },
  "_npmUser": {
    "name": "timer",
    "email": "timer150@gmail.com"
  },
  "_npmVersion": "5.3.0",
  "_phantomChildren": {
    "asap": "2.0.6",
    "escape-string-regexp": "1.0.5",
    "graceful-fs": "4.1.11",
    "has-ansi": "2.0.0",
    "universalify": "0.1.1"
  },
  "_requested": {
    "raw": "react-scripts@^1.0.7",
    "scope": null,
    "escapedName": "react-scripts",
    "name": "react-scripts",
    "rawSpec": "^1.0.7",
    "spec": ">=1.0.7 <2.0.0",
    "type": "range"
  },
  "_requiredBy": [
    "#DEV:/"
  ],
  "_resolved": "https://registry.npmjs.org/react-scripts/-/react-scripts-1.0.14.tgz",
  "_shasum": "70fe76c9beb67b136b953e875bdfe4ad78d410d1",
  "_shrinkwrap": null,
  "_spec": "react-scripts@^1.0.7",
  "_where": "D:\\Sandeepan\\Payu MVC\\backend codebase\\MVC2.0\\panel\\mvc-panel",
  "bin": {
    "react-scripts": "./bin/react-scripts.js"
  },
  "bugs": {
    "url": "https://github.com/facebookincubator/create-react-app/issues"
  },
  "dependencies": {
    "autoprefixer": "7.1.2",
    "babel-core": "6.25.0",
    "babel-eslint": "7.2.3",
    "babel-jest": "20.0.3",
    "babel-loader": "7.1.1",
    "babel-preset-react-app": "^3.0.3",
    "babel-runtime": "6.26.0",
    "case-sensitive-paths-webpack-plugin": "2.1.1",
    "chalk": "1.1.3",
    "css-loader": "0.28.4",
    "dotenv": "4.0.0",
    "eslint": "4.4.1",
    "eslint-config-react-app": "^2.0.1",
    "eslint-loader": "1.9.0",
    "eslint-plugin-flowtype": "2.35.0",
    "eslint-plugin-import": "2.7.0",
    "eslint-plugin-jsx-a11y": "5.1.1",
    "eslint-plugin-react": "7.1.0",
    "extract-text-webpack-plugin": "3.0.0",
    "file-loader": "0.11.2",
    "fs-extra": "3.0.1",
    "fsevents": "1.1.2",
    "html-webpack-plugin": "2.29.0",
    "jest": "20.0.4",
    "object-assign": "4.1.1",
    "postcss-flexbugs-fixes": "3.2.0",
    "postcss-loader": "2.0.6",
    "promise": "8.0.1",
    "react-dev-utils": "^4.1.0",
    "style-loader": "0.18.2",
    "sw-precache-webpack-plugin": "0.11.4",
    "url-loader": "0.5.9",
    "webpack": "3.5.1",
    "webpack-dev-server": "2.8.2",
    "webpack-manifest-plugin": "1.2.1",
    "whatwg-fetch": "2.0.3"
  },
  "description": "Configuration and scripts for Create React App.",
  "devDependencies": {
    "react": "^15.5.4",
    "react-dom": "^15.5.4"
  },
  "directories": {},
  "dist": {
    "integrity": "sha512-+p0q2N2WW7L4WW6uObqN7fYwSQZ9fBI0StpMYl1Ukoz/lCbemf+yW6b8refyhTsGy62GAqxlpyEfVcTE3hJAxg==",
    "shasum": "70fe76c9beb67b136b953e875bdfe4ad78d410d1",
    "tarball": "https://registry.npmjs.org/react-scripts/-/react-scripts-1.0.14.tgz"
  },
  "engines": {
    "node": ">=6"
  },
  "files": [
    "bin",
    "config",
    "scripts",
    "template",
    "utils"
  ],
  "homepage": "https://github.com/facebookincubator/create-react-app#readme",
  "license": "MIT",
  "maintainers": [
    {
      "name": "timer",
      "email": "timer150@gmail.com"
    },
    {
      "name": "fb",
      "email": "opensource+npm@fb.com"
    },
    {
      "name": "gaearon",
      "email": "dan.abramov@gmail.com"
    }
  ],
  "name": "react-scripts",
  "optionalDependencies": {
    "fsevents": "1.1.2"
  },
  "readme": "ERROR: No README data found!",
  "repository": {
    "type": "git",
    "url": "git+https://github.com/facebookincubator/create-react-app.git"
  },
  "version": "1.0.14"
}

更新资料

我尝试运行npm install命令并获取先前命令的退出状态。尽管显示警告,但显示0表示成功。因此,看起来Jenkins的工作不会因此而停滞。但是,我们仍在设法摆脱这种警告,因为它与我们的操作系统无关。


试试这个,它对我有用stackoverflow.com/a/58178041/4088675添加fsevents作为选项aDependecy
Oluwaloni Richard

Answers:


69

fsevents在Mac和其他Linux系统中处理方式有所不同。Linux系统忽略,fsevents而Mac安装。由于上述错误消息指出这fsevents是可选的,因此在安装过程中会被跳过。

您可以npm install --no-optional在linux系统中运行命令以避免上述警告。

更多的信息

https://github.com/npm/npm/issues/14185

https://github.com/npm/npm/issues/5095


15
我只是尝试运行npm install --no-optional到avoir被警告为fsevents。虽然没有工作:(
Deunz

1
不幸的是,由于npm中的错误,这会导致其他问题。参见github.com/npm/npm/issues/19877#issuecomment-368981968
TigerBear,

3
正如TigerBear所说,“-no-optional”是一个非常非常糟糕的主意。通常可以忽略警告。您还可以使用npm install -fgithub.com/angular/angular/issues/13935
FoggyDay '19

3
我如何直接将其作为可选依赖项删除,以不显示警告?
亚伦弗兰克

没有像我广告中那样工作。Ubuntu 2020
Michael Durrant

36
npm i -f

我想从重新发布一些评论这个线程,在那里你可以在这个问题上阅读起来,这个问题得到了解决

这正是Angular的问题。当前的package.json要求fsevent不是optionalDependencies,而是devDependencies。对于非OSX用户,这可能是个问题。

有时

即使将其从package.json npm中删除,我仍然会失败,因为另一个模块将其作为对等dep。

所以

如果npm-shrinkwrap.json仍然存在,请删除它或尝试npm i -f


1
怎么npm i -f办?
超级翡翠

1
有等于的纱线npm i -f吗?
超级翡翠

35

如果要隐藏此警告,则只需安装fsevents作为可选依赖项。只需执行:

npm i fsevents@latest -f --save-optional

..并且警告将不再是麻烦。


9
非Mac用户不能选择此选项。
马修


2
OP表示:“ ...试图找到一种方法来消除此警告,因为它与我们的操作系统无关”,因此您提出的解决方案无法正常工作。
matthiku

1
是否添加了“ -f”选项?
Juninho Cruz

10

package.jsonoptionalDependencies钥匙计数。 NPM关于可选依赖

您可以添加fsevents到该对象,如果发现自己在不同于MacOS的平台上安装软件包,fsevents则会被yarnnpm跳过。

"optionalDependencies": {
  "fsevents": "2.1.2"
},

您将在安装日志中找到类似以下的消息:

info fsevents@1.2.11: The platform "linux" is incompatible with this module.
info "fsevents@1.2.11" is an optional dependency and failed compatibility check. Excluding it from installation.
info fsevents@2.1.2: The platform "linux" is incompatible with this module.
info "fsevents@2.1.2" is an optional dependency and failed compatibility check. Excluding it from installation.

希望能帮助到你!


6

我发现了同样的问题,并尝试了上面和github中提到的所有解决方案。当我使用travic-CI或Pipelines将我的PR推送到远程存储库中时,有些只能在本地存储库中工作,这会给我同样的错误。最后,我使用下面的npm命令修复了它。

npm audit fix --force


问题是不是每个人都拥有,npm-audit并且当我尝试安装它时,npm install npm-audit它会彻底失败...
Serj Sagan

如果我还安装了fsevents作为可选的依赖项,这对我有用,如以下几个答案所述。
萨法阿莱


2

我在使用MacOS时也遇到了同样的问题。问题是一种错误。我通过重复运行命令解决了这个问题,

sudo npm cache clean --force 
sudo npm uninstall 
sudo npm install

一次它不起作用,但是当我反复清理缓存并卸载npm之后,重新安装npm时,错误消失了。我正在使用Angular 8,这个问题很常见


1

不必--no-optional每次都使用,我们可以将其添加到npm或yarn配置中。

对于Yarn,有一个默认的非可选配置,因此我们可以对其进行编辑:

yarn config set ignore-optional true

对于npm,没有默认配置集,因此我们可以创建一个:

npm config set ignore-optional true

0

我遇到了同样的错误。就我而言,我正在使用映射的驱动器从第二台计算机(运行Linux的计算机)上编辑代码。不确定到底为什么gulp-watch在安装之前依赖于操作系统的兼容性(我认为这与安全性有关)。本质上,错误是针对您的操作系统和调用节点模块的操作系统进行的,在我的情况下,这两个操作系统不相同,因此将其抛出错误。从您的错误来看,哪个与我的相同。

错误

Unsupported platform for fsevents@1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

我该如何解决?

我直接登录linux计算机并运行

npm install --save-dev <module-name>

然后回到我的编码环境,此后一切都很好。

希望有帮助!


使用它 npm i fsevents@latest -f --save-optional
RAVI BANGKIT NUR ZIKRILLAH

0

我正在使用Angular CLI:8.1.2节点:12.14.1操作系统:win32 x64

奇怪的是,这对我有帮助

npm cache clean --force
npm uninstall @angular/cli
npm install @angular/cli@8.1.2

-1

是的,在使用命令npm install --no-optional
使用环境时可以使用:

  • iTerm2
  • MacOS的登录到我的虚拟机ubuntu16 LTS。

-1

我在Linux系统(Ubuntu)中遇到此错误,当您运行时可能会发生:

npm安装

1)如果本地磁盘/计算机中不存在该项目,请将其复制到计算机中,然后重试。因此,您获得了访问文件夹的权限(只需确保您具有访问权限)。

2)如果仍然收到一些警告或错误,请运行:

npm审核修复

这将解决依赖关系中的漏洞,并通过提供易于运行的npm命令和建议以进行进一步的故障排除,帮助您修复漏洞。

希望能帮助到你!


-1

切换到PNPM: https

fsevents警告都走了(在Linux上)。

即使是最新的纱线(2.x)也会显示警告。


此处缺少警告可能是由于pnpm缓存依赖项的方式。您可能仍然有一次警告,但是随后的使用将只是创建符号链接,而跳过发出警告的安装。如果要清除pnpm缓存,则可能会再次出现警告。无论哪种方式,这都是“通过杀死患者来治愈疾病”的选择,而不是解决方案。
erich2k8

@ erich2k8您不正确。我清除了pnpm缓存,并且在pnpm安装过程中未出现警告。
KTCO

-2

如果有人遇到此错误,请安装离子科尔多瓦。只需npm install --no-optional在您的cmd中使用此代码即可。然后运行这段代码npm install -g ionic@latest cordova


By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.