如何在非MAC OS上解决npm install throw fsevents警告?

San*_*ath 51 fsevents node.js jenkins npm-install

以下警告被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"}
)
Run Code Online (Sandbox Code Playgroud)

警告显然导致我们的詹金斯工作标记失败,所以我们只是试图摆脱相同.

我已经检查了这个/sf/answers/3005687891/ 但是,与那里提到的不同,我的设置中没有任何/ 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"
  }
}
Run Code Online (Sandbox Code Playgroud)

我可以在react-scripts的package.json中找到fsevents(在我的package.json的devDependencies下定义)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"
}
Run Code Online (Sandbox Code Playgroud)

更新

我尝试运行npm install命令并获取先前命令的退出状态.尽管有警告,但它显示了0意味着成功.所以,看起来詹姆斯的工作不应该因此而陷入困境.但是,我们仍在努力寻找摆脱此警告的方法,因为它与我们的操作系统无关.

Jun*_*ruz 62

如果你想隐藏这个警告,你只需要安装 fsevents 作为一个可选的依赖项。只需执行:

npm i fsevents@latest -f --save-optional
Run Code Online (Sandbox Code Playgroud)

..警告将不再是一个麻烦。

  • 对于非 Mac 用户来说,这不是一个选项。 (16认同)
  • OP 说:“...试图找到一种方法来消除此警告,因为它与我们的操作系统无关”,因此您提出的解决方案不起作用。 (2认同)
  • 您添加了“-f”选项吗? (2认同)
  • 谢谢,@JuninhoCruz!它就像一个魅力。您希望扩展您的答案以提供更多详细信息吗?或者分享相关链接? (2认同)

ash*_*ai_ 44

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

  • 我如何直接将其作为可选依赖项删除而不显示警告? (6认同)
  • 正如 TigerBear 所说,“没有可选”是一个非常非常糟糕的主意。通常可以忽略该警告。您还可以使用“npm install -f”:https://github.com/angular/angular/issues/13935 (5认同)
  • 我只是试图运行npm install --no-optional到avoir被警告为fsevents。虽然没有用:( (4认同)
  • 不幸的是,由于 npm 中的错误,这会导致其他问题。见 https://github.com/npm/npm/issues/19877#issuecomment-368981968 (2认同)

sr9*_*yar 21

npm i -f
Run Code Online (Sandbox Code Playgroud)

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

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

有时

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

所以

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

  • `npm i -f` 有什么作用? (5认同)
  • 是否有相当于“npm i -f”的纱线? (5认同)

Est*_*rai 19

package.jsonoptionalDependencies钥匙算。 可选依赖项上的 NPM

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

"optionalDependencies": {
  "fsevents": "2.1.2"
},
Run Code Online (Sandbox Code Playgroud)

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

"optionalDependencies": {
  "fsevents": "2.1.2"
},
Run Code Online (Sandbox Code Playgroud)

希望能帮助到你!

  • 如果您不喜欢弄乱 JSON,请运行以下命令:npm i fsevents@latest -f --save-Optional,这会将此 JSON 添加到文件中。 (3认同)

eli*_*eli 10

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

npm audit fix --force


adl*_*lr0 6

npm v7 不再出现这种情况。您可以更新 npm 版本或更新到 Node v15 或更高版本,默认情况下安装 npm v7。

  • 你是对的。这与 Node 版本无关。这是 NPM 版本(即 NPM v7)修复的错误。对于某些人来说,了解更新到 Node v15 也会将 NPM 更新到 v7 可能会有所帮助,这就是我解释这两个选项的原因。您共享的修复是另一个有效的答案,也可以在此页面中找到。对我来说,更新 NPM 更容易,因此对于其他人来说这也可能是一个不错的选择,这就是为什么我分享了对我有帮助的内容。 (3认同)

Ayu*_*pta 6

按着这些次序 -

  1. 转到项目的“package.lock.json”文件
  2. 按“Ctrl+F”(启用搜索)
  3. 输入“达尔文”
  4. 将其重命名为“linux”

节点_模块_fs事件