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

23

183

Following warning is being thrown on npm install command -

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.

I already checked this https://mcmap.net/q/137642/-npm-install-fsevents-errors 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": "[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.

Chatman answered 25/10, 2017 at 9:49 Comment(2)
Try this, it worked for me https://mcmap.net/q/137643/-npm-error-unsupported-platform-for-fsevents-when-deploying-to-azure Adding fsevents as an optionaDependecyMucous
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.Tadpole
R
98

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

Rouvin answered 2/11, 2017 at 9:23 Comment(5)
I just tried to run npm install --no-optional to avoir being warned for fsevents. Didn't work though :(Eiderdown
unfortunately this leads to other problems due to a bug in npm. See github.com/npm/npm/issues/19877#issuecomment-368981968Hm
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: github.com/angular/angular/issues/13935Afroamerican
How do I just straight up remove it as an optional dependency to not show the warning?Rella
Did not work as advertised for me. Ubuntu 19.04 Jan 2020Benbena
I
76

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.

Ison answered 23/10, 2019 at 4:15 Comment(9)
This is not an option for non-Mac users.Olympia
the OP said: "...trying to find a way to get rid of this warning because it is not relevant to our OS" so your proposed solution is not working.Angola
Have you added the "-f" option?Ison
This solved my deploy to Heroku, which was failing because of the fsevents dependency. Brilliant!Dimerous
This command line works on Linux and silences the warning. Side effects unknown.Mitinger
Thank you sir, out ot many answers I tried, this one worked.Amenity
Thanks, Man. worked perfectly for me I'm a Linux Mint user.Battista
Thanks, @JuninhoCruz! It worked like a charm. Would you like you to extend your answer to provide more details? Or perhaps share relevant links?Godman
This worked for me to deal with my local build being MacOS and my Bitbucket build being linuxRevolving
K
41
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

Kaylee answered 18/4, 2018 at 6:49 Comment(4)
What does npm i -f do?Hoad
Is there a yarn equivalent to npm i -f?Hoad
According to the doc > The -f or --force argument will force npm to fetch remote resources even if a local copy exists on disk.Blakeley
Seem most suitable for cracksAmicable
B
28

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 [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!

Bedizen answered 15/12, 2019 at 23:23 Comment(3)
If you don't like messing with JSON, run this command: npm i fsevents@latest -f --save-optional, which willl add this JSON to the file for you.Duky
This indeed removes the warning on LinuxBlakeley
I still get the warning...Midwife
D
12

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

Dakar answered 22/7, 2019 at 13:11 Comment(5)
Problem is that not everyone has npm-audit and when I try to install it with npm install npm-audit it fails drastically...Prussian
This worked for me provided I also had fsevents installed as an optional dependency as described by several answers here.Makebelieve
npm audit is a command from npm itself, and there's no package called npm-audit.Odine
@DavidWheatley you are right, but this was a solution for npm fails.Dakar
Worked for me. Facing this issue during Jenkins build bindings not accessible from jest-haste-map:fsevents.Prevost
E
6

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.

Entremets answered 29/3, 2021 at 12:3 Comment(5)
not true. It happened with my node 12.12.0 and still happening after I updated it to v14.17.0Ciliata
Make sure npm -v tells you your npm version is 7 or higher. Because the default npm version bundled with those two versions of node is lower than 7. As said in my answer, you can also upgrade to node 15, which bundles npm 7.Entremets
The point is that the issue has nothing to do with node version, that is what I wrote above. This resolved the issue #46929696 actually a comment on that 'npm i fsevents@latest -f --save-optional'Ciliata
You are right. This is not related to Node version. This is a bug fixed by an NPM version, namely NPM v7. For some people, it might be helpful to know that updating to Node v15 also updates NPM to v7, and that is why I explained both options. That fix you shared is another valid answer, also available in this page. For me, it was easier to just update NPM so it might also be a good option for other people and that is why I shared what helped me.Entremets
Ok I see. Seems a case where more then one solution "works"Ciliata
F
6

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

Flunky answered 11/4, 2021 at 16:22 Comment(2)
5. delete node_modules folder 6. reinstall packages by running npm I This works when you also add the steps above.Sentimentalism
darwin doesn't appear in that file for me on MacOSRevolving
P
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

Pigpen answered 1/8, 2019 at 8:22 Comment(0)
T
3

Do this:

npm install --no-optional

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

Tourist answered 24/11, 2017 at 14:57 Comment(0)
F
3

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/[email protected]
Found answered 5/6, 2020 at 7:54 Comment(1)
That npm cache clean --force ended up helping me in not exactly the same matter, but another matter regarding fsevents dependencies.Papst
S
3

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
Seaver answered 24/9, 2020 at 10:46 Comment(0)
R
2

For anyone reading it recently, the simplest thing to do on Ubuntu is to install the latest LTS versions of nvm, node.js, and nmp. from version 7 of node.js, these issues have been sorted out.

Refer to this guide: https://computingforgeeks.com/how-to-install-node-js-on-ubuntu-debian/

Ramonaramonda answered 2/11, 2021 at 10:46 Comment(0)
P
1

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

Prurient answered 14/3, 2021 at 22:27 Comment(0)
G
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 [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

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

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

Hope that helps!

Gregoor answered 7/3, 2018 at 0:9 Comment(2)
use this npm i fsevents@latest -f --save-optionalAnxious
yep "npm i fsevents@latest -f --save-optional" did worked also in my case.Ciliata
M
0

run npm install -D vue-loader vue-template-compiler Vue CLI If you are not interested in manually setting up webpack, it is recommended to scaffold a project with Vue CLI instead. Projects created by Vue CLI are pre-configured with most of the common development needs working out of the box.

Follow this guide if the built-in configuration of Vue CLI does not suit your needs, or you'd rather create your own webpack config from scratch.

#Manual Setup #Installation Unless you are an advanced user using your own forked version of Vue's template compiler, you should install vue-loader and vue-template-compiler together:

Montford answered 30/9, 2021 at 5:56 Comment(0)
P
0

Check your node version and check if the package.json was generate using a different version of node.

I downloaded a repo created from Mac from a Linux and faced this error when trying to npm install. I was using node v14.15.0 and when I switched to v16.13.0, the error disappeared.

Pyrolysis answered 15/11, 2021 at 14:26 Comment(0)
C
0

The following argument works for me:

--omit=optional

Cordy answered 20/9, 2023 at 19:7 Comment(0)
C
0

I was initially trying to install several Node.js modules using the command:

npm install express cookie-parser body-parser sqlite3 sequelize bcrypt ejs

with node-v18.18.2, so it led me here.

Current version: node-v17.9.1, because I uninstalled node-v18.18.2 and downgraded as suggested on the web but didn't worked. Luckily;

npm audit fix --force

This solution was provided by Eli, and it worked for me.

I hope this helps you with your Node.js and npm-related issues. If you have more questions or need further assistance, feel free to ask!

Ceciliacecilio answered 17/10, 2023 at 17:51 Comment(0)
C
-1

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

  • iTerm2
  • macos login to my vm ubuntu16 LTS.
Cheatham answered 24/2, 2018 at 9:3 Comment(0)
W
-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!

Ward answered 24/10, 2018 at 5:35 Comment(0)
W
-1

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

The fsevents warnings are gone (on Linux).

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

Worked answered 8/8, 2020 at 3:2 Comment(2)
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.Volar
@erich2k8 You are incorrect. I cleared the pnpm cache and the warning does not appear during pnpm install.Worked
F
-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

Forgo answered 22/3, 2018 at 13:22 Comment(0)
M
-11

Use sudo npm install -g appium.

Miguel answered 7/6, 2020 at 18:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.