npm install error (code EBADPLATFORM) - node.js

When I tried to run npm install, it gave me this error:
$ npm install
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
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Aroma\AppData\Roaming\npm-cache\_logs\2018-03-
25T11_33_58_338Z-debug.log
The node version:
$node -v
v8.10.0
I tried every thing, like:
npm cache clear
npm cache verify
npm i -g npm#latest
I even tried uninstalling and reinstalling Nodejs again but still get the same error.

I had the same issue, deleting my "package-lock.json" and re-running npm install worked
For those having issue on render.com
remove package-lock.json from your repo or add to gitignore
then run the build command npm install ; npm run build using the build from last comment option on render.com dashboard

Error is indicating that you are installing fsevents module in other OS rather than Mac
fsevents module only works for Mac Operting system

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.

Add following to your project's package.json
"optionalDependencies": {
"fsevents": "*"
},
and then install with --no-optional

Same npm install error (code EBADPLATFORM):
I had forced fsevents onto my windows machine npm i -f fsevents...
npm responded "I hope you know what your doing".
To repair, needed to
delete package-lock.json
delete line: fsevents#2.3.2 in package.json (your suffix may differ)
re-ran npm install

Remove "fsevents": "version", on package.json if you try to install on Windows.

I'm developing on Mac. I deleted "os": [ "darwin" ] from package.lock.json, ran the build, deployed to my Google Cloud App Engine project, and it finally worked.
Source: belykh's comment (Nothing posted in any of the other answers helped me.)

The error says it all:
Unsupported platform for fsevents#1.1.3:
wanted {"os":"darwin","arch":"any"}
(current: {"os":"win32","arch":"x64"})
This module doesn't support Windows, you can't use it if you're on Windows.

I think In your Project Folder First Delete package.lock.json and then try:
npm install
This is Works For Me.

I had this same issue on my dev machine (Win 10 x64). I had no intention of running or using fsevents locally. I just needed to upgrade my local copy of fsevents, to resolve a vulnerability. Running with the -f option solved it:
npm install fsevents#1.2.9 -f
Note: -f means "force installation". npm gives an ominous warning like "I hope you know what you're doing". Afaik fsevents isn't dangerous to have on a win32 machine. It only "works" on mac. The npm page for fsevents says "This is a low-level library. For a cross-platform file watching module that uses fsevents, check out Chokidar". I was only upgrading and wasn't choosing to use it on a win32 machine. So keep that in-mind.
That being-said, it didn't break anything for me. No BSoDs, errors, etc. App still works. Build works. All good.

This error message says that fsevents package does not support your operating system. In my case the solution for this error was to upgrade npm to the latest version.

please first delete package-lock.json file and remove "win-node-env": "^0.4.0" this line from package.json

This is what worked for me:
Delete node_modules
Delete package-lock.json
run npm i

Add peer dependency in your JSON package like below
{
"name": "chai-as-promised",
"peerDependencies": {
"chai": "1.x"
}
}

Related

Angular cli not working in Git Bash terminal on Windows

I've been trying to install the Angular CLI via npm. My current node version is v11.2.0 and my npm version is 6.4.1.
After running the command npm install -g #angular/cli I get this output:
C:\Users\Mark O'Hare\AppData\Roaming\npm\ng -> C:\Users\Mark O'Hare\AppData\Roaming\npm\node_modules\#angular\cli\bin\ng
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.2.4 (node_modules\#angular\cli\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
and when I try ng -v I get this error message:
internal/modules/cjs/loader.js:605
throw err;
^
Error: Cannot find module 'C:\c\Users\Mark O'Hare\AppData\Roaming\npm\node_modules\#angular\cli\bin\ng'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:603:15)
at Function.Module._load (internal/modules/cjs/loader.js:529:25)
at Function.Module.runMain (internal/modules/cjs/loader.js:775:12)
at startup (internal/bootstrap/node.js:300:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:826:3)
Things I've tried so far:
Uninstalling angular via npm and reinstalling
Uninstalling node.js and deleting npm folders, restarting machine and reinstalling
Creating alias's for 'ng' with the path to the ng file in the npm node_modules folder
So far none of these have worked. Can anyone help or suggest a workaround?
I guess the problem lies within the user folder Mark O'Hare:
Error: Cannot find module 'C:\c\Users\Mark O'Hare\AppData\Roaming\npm\node_modules\#angular\cli\bin\ng' --> it reads the string until the second apostrophe, which is inside O'Hare, ultimately reading the folder as
C:\c\Users\Mark O
You can also try to use linux subsystem.
I would recommend it as it's easier to make JS env working.
https://learn.microsoft.com/en-us/windows/wsl/install-win10
i think folder name Mark O'Hare is the issue.
Instead of global installation try to install it in local and try to run the cli

Npm error unsupported platform for fsEvents when deploying to Azure

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
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"
}
#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)
fsevents is an OS X-only module, you can't install it on Windows.
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",
},
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 ).
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"
}
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.
add this it works for me
"main": "server.js",
"type": "module",
"engines": { "node": "16.10.0", "npm": "7.24.2" },

npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents

I'm trying to run this project.
After updating minimatch version to 3.10.9, I'm getting the following error:
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#^1.0.0 (node_modules\webpack\node_modules\watchpack\node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.0.14: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"ia32"})
My configuration:
Node v - 4.4.2
npm v - 3.10.9
32 bit windows OS
It's a warning, not an error. It occurs because fsevents is an optional dependency, used only when project is run on macOS environment (the package provides 'Native Access to Mac OS-X FSEvents').
And since you're running your project on Windows, fsevents is skipped as irrelevant.
There is a PR to fix this behaviour here: https://github.com/npm/cli/pull/169
This still appears to be an issue, causing package installations to be aborted with warnings about optional packages not being installed because of "Unsupported platform".
The problem relates to the "shrinkwrap" or package-lock.json which gets persisted after every package manager execution. Subsequent attempts keep failing as this file is referenced instead of package.json.
Adding these options to the npm install command should allow packages to install again.
--no-optional argument will prevent optional dependencies from being installed.
--no-shrinkwrap argument, which will ignore an available package lock or
shrinkwrap file and use the package.json instead.
--no-package-lock argument will prevent npm from creating a package-lock.json file.
The complete command looks like this:
npm install --no-optional --no-shrinkwrap --no-package-lock
nJoy!
Using parameter --force:
npm i -f
This answer worked for me, add this to your package.json
"optionalDependencies": {
"fsevents": "^2.3.2"
}
Unsupported platform for fsevents
The current best solution is upgrading your version of npm, which won't have this warning.
If using a Windows machine, an easy way to upgrade is with the tool Upgrade npm on Windows.

What does 'invalid' mean when using npm list?

I am new to nodejs and i had just installed bower module globally. Ever since then, npm list command gives the following output which I searched for on the web but couldn't find any help :
**npm ERR! invalid: chalk#0.5.1 /usr/local/lib/node_modules/bower/node_modules/chalk
npm ERR! invalid: ansi-regex#0.2.1 /usr/local/lib/node_modules/bower/node_modules/chalk/node_modules/has-ansi/node_modules/ansi-regex
npm ERR! invalid: configstore#0.3.1 /usr/local/lib/node_modules/bower/node_modules/update-notifier/node_modules/configstore
npm ERR! invalid: object-assign#0.3.1 /usr/local/lib/node_modules/bower/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/node_modules/got/node_modules/object-assign
npm ERR! invalid: registry-url#0.1.1 /usr/local/lib/node_modules/bower/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/node_modules/registry-url
npm ERR! invalid: strip-ansi#0.2.2 /usr/local/lib/node_modules/bower/node_modules/update-notifier/node_modules/string-length/node_modules/strip-ansi
npm ERR! not ok code 0**
The rest of the output is normal and lists the installed modules. Can anyone explain what's going on?
I was getting this error having the same package installed both in "dependencies" and "devDependencies" with different versions.
It means that something depends on, for example, "async":"0.9.3" but when they do require("async"), npm thinks that they'll get some other version. And also check that the dependencies and their versions listed in your package.json file are available.
If everything is right then you can solve this problem with
npm update
followed by
npm install.
I was getting this error after installing a newer version of a module, without updating my package.json. So the package.json required the older version, while npm list was detecting a newer version in my node_modules directory.
Running the following command got me rid of the message.
npm install {required_module}#{new_version} --save
Simplest answer
This can arise when the installed version of a package does not correspond to what package.json would install.
Example
Say you have specified "axios": "0.19.2", in your package.json, but after that you would install a specific version using npm install axios#0.18.1.
An npm list | grep axios would now yield
├─┬ axios#0.18.1 invalid
Follow the instructions in this answer on how to fix it.
I was getting a related but different error (but ended up here, so I'm answering here) where after running npm update I'd get. (No such issue with npm install, fwiw)
myapp#1.0.0 /home/malcolm/myapp
├── beeminder#1.4.3 invalid
The beeminder package is one I maintain, so in my main app I had set its semver to latest. This seemed to work fine before, but I guess a newer version of npm doesn't like it.
I figured it was reasonable to just use ^1.4.3 because if I'm introducing new changes then I probably am changing my own code anyway. But if for some weird reason you need the latest latest of a package (including breaking changes!) then you can use >= as a prefix instead of ^.

How to override a npm install version check failure?

Is there a way to override npm's version checking against a packages.json file from command line (npm install command)?
I would like to try and install/run a package even though it doesn't match my node.js version.
This is the error I am getting:
npm ERR! Unsupported
npm ERR! Not compatible with your version of node/npm: canvas#0.6.0
npm ERR! Required: {"node":"0.4.x"}
npm ERR! Actual: {"npm":"1.0.8","node":"v0.5.0-pre"}
Thanks
What you could do is go to github package and update the package.json. Then just install it locally. But most of the times these version numbers are there for a reason. The node.js api changes sometimes(I believe 0.5.0-pre changed, because socket.io also fails with 0.5.0-pre).
If you for example install nvm, nave you can keep several version of node.js side-by-side easily.
If all else fails you could still manually download and copy the files in your node_modules folder

Resources