I was learning vuepress and tried make a small blog site and decided to deploy it on netlify and it gave me this error. After some googling I found that removing package-lock.json
would help but I am facing the same error after deleting package-lock.json
5:57:41 PM: npm ERR! code EBADPLATFORM
5:57:41 PM: npm ERR! notsup Unsupported platform for [email protected]: wanted {"os":"win32","arch":"x64"} (current: {"os":"linux","arch":"x64"})
5:57:41 PM: npm ERR! notsup Valid OS: win32
5:57:41 PM: npm ERR! notsup Valid Arch: x64
5:57:41 PM: Creating deploy upload records
5:57:41 PM: npm ERR! notsup Actual OS: linux
I am using Vite as package manager.It is running fine in local server.
TL;DR;
Try running
npm update
to update theesbuild
package dependencies in yourpackage-lock.json
file.Background
First, you should not remove your
package-lock.json
file. It is an important file with a purpose and should remain version controlled (https://nodejs.dev/learn/the-package-lock-json-file).I believe the issue is that vite uses
esbuild
.esbuild
lists a number ofoptionalDependencies
:Each of these dependencies lists a CPU and OS it depends on, like in your error:
For some reason, up to a certain version of
esbuild
these dependencies cause Netlify to think these platforms are required and thus it fails because its container is running Linux. Updating to at least version 0.14.36 fixed the problem for me, there's an ever newer version out than that at the time of this writing. You will still see warnings such asbut the build will no longer fail.