140

Following warning is being thrown on npm install command -

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"}
)

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

I already checked this https://stackoverflow.com/a/42938398/351903 But, 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 -

{
  "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 -

{
  "_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"
}

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.

Sandeepan Nath
  • 8,771
  • 17
  • 66
  • 131
  • Try this, it worked for me https://stackoverflow.com/a/58178041/4088675 Adding fsevents as an optionaDependecy – Oluwaloni Richard Mar 12 '20 at 11:32
  • I don't understand: is it a problem to fix the issue in the fsevents? The library site states that this audit error isn't a bug of the library, it's a bug of NPM. Why? Assuming that we have 1000 dependencies intended to use ONLY with a specific OS, we'll get 1000 audit errors! So, the authors of fsevents propose to fix EACH SUCH issue by reporting a bug to NPM. What if OS was built so that all command bugs were handled by the kernel? AFAIK, it's a road to hell. – Dmitry Ovchinnikov May 16 '21 at 05:53

18 Answers18

79

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

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

Further information

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

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

ashisrai_
  • 5,894
  • 2
  • 22
  • 42
  • 22
    I just tried to run npm install --no-optional to avoir being warned for fsevents. Didn't work though :( – Deunz Mar 12 '19 at 15:00
  • 2
    unfortunately this leads to other problems due to a bug in npm. See https://github.com/npm/npm/issues/19877#issuecomment-368981968 – TigerBear Mar 14 '19 at 12:58
  • 4
    As TigerBear says, "--no-optional" is a really, really Bad Idea. It's usually OK to ignore the warning. You can also use `npm install -f`: https://github.com/angular/angular/issues/13935 – FoggyDay Oct 14 '19 at 16:17
  • 5
    How do I just straight up remove it as an optional dependency to not show the warning? – Aaron Franke Oct 24 '19 at 15:00
  • Did not work as advertised for me. Ubuntu 19.04 Jan 2020 – Michael Durrant Feb 09 '20 at 12:42
58

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

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

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

Juninho Cruz
  • 944
  • 8
  • 8
38
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.

Sometimes

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

So

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

sr9yar
  • 3,453
  • 1
  • 38
  • 51
17

package.json counts with a optionalDependencies key. NPM on Optional Dependencies.

You can add fsevents to this object and if you find yourself installing packages in a different platform than MacOS, fsevents will be skipped by either yarn or npm.

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

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

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.

Hope it helps!

Esteban Borai
  • 1,436
  • 11
  • 17
9

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.

npm audit fix --force

Serj Sagan
  • 24,625
  • 17
  • 133
  • 166
eli
  • 6,774
  • 3
  • 26
  • 37
4

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,

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

adiga
  • 28,937
  • 7
  • 45
  • 66
Parthan_akon
  • 109
  • 1
  • 8
4

Instead of using --no-optional every single time, we can just add it to npm or yarn config.

For Yarn, there is a default no-optional config, so we can just edit that:

yarn config set ignore-optional true

For npm, there is no default config set, so we can create one:

npm config set ignore-optional true
colourCoder
  • 1,227
  • 2
  • 7
  • 17
2

Do this:

npm install --no-optional

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

eddie
  • 1,256
  • 3
  • 15
  • 19
Siddhartha
  • 1,073
  • 10
  • 9
2

I'm using, Angular CLI: 8.1.2 Node: 12.14.1 OS: win32 x64

Strangely, this helped me

npm cache clean --force
npm uninstall @angular/cli
npm install @angular/cli@8.1.2
Pallavi
  • 414
  • 1
  • 9
  • 1
    That npm cache clean --force ended up helping me in not exactly the same matter, but another matter regarding fsevents dependencies. – josh Nov 04 '20 at 22:42
0

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.

The Error

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

How I fixed it?

I logged into the linux computer directly and ran

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

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

Hope that helps!

ARLCode
  • 621
  • 6
  • 18
0

I solved this by deleting the node_modules folder and running npm i.

Daniel Elkington
  • 1,086
  • 2
  • 15
  • 30
0

This no longer happens with npm v7. You can update your npm version or update to node v15 or higher, which by default installs npm v7.

adlr0
  • 615
  • 8
  • 13
0

Follow these steps -

  1. Go to the project's "package.lock.json" file
  2. Press "Ctrl+F" (to enable search)
  3. Type "darwin"
  4. Rename it to 'linux'

node_module_fsevents

Ayush Gupta
  • 77
  • 2
  • 5
-1

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

  • iTerm2
  • macos login to my vm ubuntu16 LTS.
Stphane
  • 3,216
  • 5
  • 28
  • 37
Gu Steven
  • 1
  • 1
-1

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

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).

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

npm audit fix

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.

Hope it helps!

Harish Kulkarni
  • 647
  • 4
  • 15
-1

Switch to PNPM: https://pnpm.js.org/

The fsevents warnings are gone (on Linux).

Even the latest yarn (2.x) shows the warnings.

KTCO
  • 1,837
  • 18
  • 19
  • 1
    The lack of the warning here is likely due the way that pnpm caches dependencies. You probably still had the warning once, but subsequent uses would simply be creating symlinks, skipping the installation that issues the warning. If you were to clear your pnpm cache, you would likely have the warnings again. Either way, this is a "cure the disease by killing the patient" option, not a solution. – erich2k8 Sep 18 '20 at 01:27
  • @erich2k8 You are incorrect. I cleared the pnpm cache and the warning does not appear during pnpm install. – KTCO Sep 30 '20 at 16:12
-2

If anyone get this error for ionic cordova install . just use this code npm install --no-optional in your cmd. And then run this code npm install -g ionic@latest cordova

-9

Use sudo npm install -g appium.

double-beep
  • 3,889
  • 12
  • 24
  • 35
Babue
  • 1