27

When I run npm install, I get this error:

npm ERR! code EBADPLATFORM npm ERR! notsup Unsupported platform for
fsevents@1.1.3: wanted {"os":"darwin","arch":"any"} (current:
{"os":"win32","arch":"x64"}) npm ERR! notsup Valid OS:    darwin npm
ERR! notsup Valid Arch:  any npm ERR! notsup Actual OS:   win32 npm
ERR! notsup Actual Arch: x64

This has been asked here but the accepted answer that it is optional does not work for me as I am unable to publish to azure since npm install fails.

npm version : 5.6.0

I have tried:

npm install --no-optional
Soham Dasgupta
  • 5,061
  • 24
  • 79
  • 125
Curious-programmer
  • 772
  • 3
  • 13
  • 31

9 Answers9

24

npm i -f doesn't sound like a good idea...

Instead, add fsevents to optional dependencies (if fsevents is in your package.json):

"optionalDependencies": {
    "fsevents": "^2.0.7"
}
Benjamin Piette
  • 3,645
  • 1
  • 27
  • 24
  • 1
    optionalDependencies works great for situations where you have multiple environments like developing on a Windows machine running Alpine or Centos Docker images to simulate production which is Linux. Each environment should be using its own node_modules directory though. Do not use bind mounts or copy node_modules, doing so will invite catastrophe into your deployments. – Greg Jan 29 '20 at 20:56
15

@Aaron is correct. This was failing when I was running npm install from within maven-frontend-plugin.

I resolved the issue using the command npm i -f ( npm install forced)

Oliver
  • 6,152
  • 2
  • 42
  • 75
  • This is a common, getting code compiled from another dev, then having node_modules and .lock files attached to it. If the prior dev installed modules i.e. from a Mac computer, then you can't work with them. – m3nda Sep 29 '21 at 05:08
7

fsevents is an OS X-only module, you can't install it on Windows.

Aaron Chen
  • 9,835
  • 1
  • 16
  • 28
  • 2
    @Aarob Chen How do I work around it? I don't know why it is attempting to install it? – Curious-programmer Feb 21 '18 at 05:28
  • 1
    Have you checked @lacolaco‘s answers at this link: https://github.com/angular/angular/issues/13935? – Aaron Chen Feb 21 '18 at 05:52
  • 1
    This answer is definitely true, but sometimes it's required farther down the dependency tree and NPM fails the install even though it's listed as an optional dependency. This, at least, is the case with the latest versions of NPM (v7+) and it seems to be a recurring problem through time since it was reported years ago, before the current major versions existed. – cwadrupldijjit Jun 03 '21 at 23:19
6

fsevents is only needed if you are building on a Mac. If you are deploying to ubuntu, windows, etc it's not needed.

See here npm package.json OS specific dependency which reads,

npm package.json supports an os key,

and also optionalDependencies

os can be used to specify which OS a module can be installed on. optionalDependencies are module dependencies that if they cannot be installed, npm skips them and continues installing.

Either one will work. I prefer adding the following to my package.json's root object:

"optionalDependencies": {
    "fsevents": "^2.1.2",
  },
John
  • 976
  • 1
  • 15
  • 21
1

It is nothing to deal with Darwin or Windows . You might have installed the Angular but system variable path is not updated accordingly .

Get the ng install location from your system something like(C:\Users.....\AppData\Roaming\npm) and add at the end of system variable path .

now go to Cmd -> type ng-v for Angular 6 ( ng v or ng version for Angular 7 ).

Pratik Roy
  • 117
  • 1
  • 3
0

I know this question is old, but for other people still facing this issue especially on mac0S, there seems to be some platform specificity issue around the whole thing. I encountered the problem while trying to deploy to Heroku, I did the following, the build became successful and the deployment worked afterward. So kindly do the following:

  • Add your preferred version of fsevents to optionalDependencies in your package.json
  • Run npm install afterward.
  • I assume you do not currently have an entry for optionalDependencies in your package.json, so here you go:

    "optionalDependencies": { "fsevents": "2.x.x" }

Benneee_
  • 319
  • 1
  • 7
0

This worked effortless for me on Windows:

Go to project's "package.lock.json" file Press "Ctrl+F" (to enable keyword search) Type "darwin" Wherever it says "darwin" in the file, change that to "win32" Restart your VS Code and you should be good to go.

Dharman
  • 30,962
  • 25
  • 85
  • 135
ilenikiiyala
  • 131
  • 1
  • 3
0

add this it works for me "main": "server.js", "type": "module", "engines": { "node": "16.10.0", "npm": "7.24.2" },

Vijay Anand.M
  • 81
  • 1
  • 1
0

In my case, for some wierd reason, I found that there were changes in package-lock.json that occured after runing npm install and npm build. After restoring the changes I got rid off the error

Alta
  • 11
  • 2