node.js 如何解决 npm install 在非 MAC 操作系统上抛出 fsevents 警告?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/46929196/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 18:33:06  来源:igfitidea点击:

How to solve npm install throwing fsevents warning on non-MAC OS?

node.jsjenkinsnpm-installfsevents

提问by Sandeepan Nath

Following warning is being thrown on npm installcommand -

根据npm install命令发出以下警告-

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (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"}
)

The warning is apparently causing our Jenkins Job to mark failed, so we are just trying to get rid of the same.

该警告显然导致我们的 Jenkins 作业标记为失败,因此我们只是想摆脱它。

I already checked this https://stackoverflow.com/a/42938398/351903But, unlike what is mentioned there, I do not have any /node_modules/fserrors in my setup. Also, my package.json does not contain fserrors. Following is my package.json -

我已经检查过这个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"
  }
}

I can see fsevents in the package.json of react-scripts (which is defined under devDependencies of my package.json) in node_modules\react-scripts\package.json-

我可以在 react-scripts(在我的 package.json 的 devDependencies 下定义)的 package.json 中看到 fsevents 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": "[email protected]",
  "_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": "[email protected]"
  },
  "_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": "[email protected]"
    },
    {
      "name": "fb",
      "email": "[email protected]"
    },
    {
      "name": "gaearon",
      "email": "[email protected]"
    }
  ],
  "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"
}

Update

更新

I tried running the npm install command and getting the exit status of the earlier command. It showed 0 meaning success, despite the warnings. So, it does not look like Jenkins job should be stuck due to this. However, we are still trying to find a way to get rid of this warning because it is not relevant to our OS.

我尝试运行 npm install 命令并获取先前命令的退出状态。尽管有警告,但它显示 0 表示成功。因此,看起来 Jenkins 的工作不应该因此而被卡住。但是,我们仍在尝试找到一种方法来消除此警告,因为它与我们的操作系统无关。

回答by ashisrai_

fseventsis dealt differently in mac and other linux system. Linux system ignores fseventswhereas mac install it. As the above error message states that fseventsis optional and it is skipped in installation process.

fsevents在 mac 和其他 linux 系统中处理不同。Linux 系统忽略fsevents而 mac 安装它。由于上面的错误消息指出这fsevents是可选的,并且在安装过程中被跳过。

You can run npm install --no-optionalcommand in linux system to avoid above warning.

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

Further information

更多信息

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

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

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

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

回答by sr9yar

npm i -f

I'd like to repost some comments from this thread, where you can read up on the issue and the issue was solved.

我想重新发布此线程的一些评论,您可以在其中阅读该问题并解决了该问题

This is exactly Angular's issue. Current package.json requires fsevent as not optionalDependencies but devDependencies. This may be a problem for non-OSX users.

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

Sometimes

有时

Even if you remove it from package.json npm i still fails because another module has it as a peer dep.

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

So

所以

if npm-shrinkwrap.json is still there, please remove it or try npm i -f

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

回答by António César Júnior

If you want to hide this warn, you just need to install fsevents as a optional dependency. Just execute:

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

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

..And the warn will no longer be a bother.

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

回答by Esteban Borai

package.jsoncounts with a optionalDependencieskey. NPM on Optional Dependencies.

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

You can add fseventsto this object and if you find yourself installing packages in a different platform than MacOS, fseventswill be skipped by either yarnor npm.

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

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

You will find a message like the following in the installation log:

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

info [email protected]: The platform "linux" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
info [email protected]: The platform "linux" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.

Hope it helps!

希望能帮助到你!

回答by eli

I found the same problem and i tried all the solution mentioned above and in github. Some works only in local repository, when i push my PR in remote repositories with travic-CI or Pipelines give me the same error back. Finally i fixed it by using the npm command below.

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

npm audit fix --force

npm audit fix --force

回答by Parthan_akon

I also had the same issue though am using MacOS. The issue is kind of bug. I solved this issue by repeatedly running the commands,

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

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

One time it did not work but when I repeatedly cleaned the cache and after uninstalling npm, reinstalling npm, the error went off. I am using Angular 8 and this issue is common

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

回答by Siddhartha

Do this:

做这个:

npm install --no-optional

For more info on this go through: https://github.com/npm/npm/issues/11632

有关此过程的更多信息:https: //github.com/npm/npm/issues/11632

回答by Harish Kulkarni

I had got this error, Linux system(Ubuntu) and This might happen when you run :

我遇到了这个错误,Linux 系统 (Ubuntu) 并且当您运行时可能会发生这种情况:

npm install

安装

1) If the project is not present in your localdisk/computer, copy it to your computer and try again. So you get the permission to access folder (Just make sure you have access permission).

1) 如果您的本地磁盘/计算机中不存在该项目,请将其复制到您的计算机并重试。所以你得到了访问文件夹的权限(只要确保你有访问权限)。

2) If you still get some warnings or errors, run:

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

npm audit fix

npm 审计修复

This will solve vulnerabilities in your dependencies and can help you fix a vulnerability by providing simple-to-run npm commands and recommendations for further troubleshooting.

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

Hope it helps!

希望能帮助到你!

回答by ARLCode

I got the same error. In my case, I was using a mapped drive to edit code off of a second computer, that computer was running linux. Not sure exactly why gulp-watch relies on operating system compatibility prior to install (I would assume it has to do with security purposes). Essentially the error is checking against your operating system and the operating system calling the node module, in my case the two operating systems were not the same so it threw it error. Which from the looks of your error is the same as mine.

我得到了同样的错误。就我而言,我使用映射驱动器从第二台计算机上编辑代码,该计算机运行的是 linux。不确定为什么 gulp-watch 在安装之前依赖于操作系统兼容性(我认为它与安全目的有关)。本质上,错误是检查您的操作系统和调用节点模块的操作系统,在我的情况下,这两个操作系统不一样,所以它抛出了错误。从你的错误来看,这和我的一样。

The Error

错误

Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

How I fixed it?

我是怎么修的?

I logged into the linux computer directly and ran

我是直接登录linux电脑跑的

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

Then went back into my coding environment and everything was fine after that.

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

Hope that helps!

希望有帮助!

回答by Gu Steven

Yes, it works when with the command npm install --no-optional
Using environment:

是的,它在使用命令npm install --no-optional
Using environment 时有效:

  • iTerm2
  • macoslogin to my vm ubuntu16 LTS.
  • iTerm2
  • macos登录到我的 vm ubuntu16 LTS。