unjs / nitro

Next Generation Server Toolkit. Create web servers with everything you need and deploy them wherever you prefer.
https://nitro.unjs.io
MIT License
5.5k stars 472 forks source link

[firebase] firebase builds can break on macos #1367

Closed Hebilicious closed 10 months ago

Hebilicious commented 1 year ago

Environment

Reproduction

https://github.com/unjs/nitro-deploys

Describe the bug

If one dependency uses fsevents, running NITRO_PRESET=firebase npm run build will create an un-deployable project.

To fix it, the .output/server/package.json and node_modules directories needs to be altered manually to remove the fsevents dependency, which is macos only and will break cloudbuild.

This should happen on macos only, windows and linux should be fine.

Additional context

We can fix it by filtering out fsevents in the firebase preset, since we should be targeting linux and not for darwin, regardless of the environment firebase deploy is being run in.

Logs

i  functions: creating Node.js 18 (2nd Gen) function server(us-central1)...
Build failed with status: FAILURE and message: npm ERR! code EBADPLATFORM
npm ERR! notsup Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin"} (current: {"os":"linux","arch":"x64"})
npm ERR! notsup Valid OS:    darwin
npm ERR! notsup Valid Arch:  undefined
npm ERR! notsup Actual OS:   linux
npm ERR! notsup Actual Arch: x64

npm ERR! A complete log of this run can be found in:
npm ERR!     /www-data-home/.npm/_logs/2023-07-01T17_56_37_753Z-debug-0.log. For more details see the logs at https://console.cloud.google.com/cloud-build/builds;region=us-central1/3622450c-555e-4490-9d09-9e5dfa875243?project=416452184607.

Functions deploy had errors with the following functions:
        server(us-central1)
i  functions: cleaning up build files...

Error: There was an error deploying functions
davemg3 commented 3 weeks ago

Having similar issue with 2 packages attached to Nuxt-seo package https://nuxtseo.com/nuxt-seo/getting-started/what-is-nuxt-seo

                "@css-inline/css-inline": "0.14.1",
                "@resvg/resvg-js": "2.6.2",

When using Nitro server preset: firebase on my Window machine, it adds in ".output/server", 4 packages :

  "@css-inline/css-inline":"0.14.1",
@css-inline/css-inline-win32-x64-msvc":"0.14.1",
"@resvg/resvg-js":"2.6.2"
"@resvg/resvg-js-win32-x64-msvc"

with following error message :

i  functions: updating Node.js 20 (2nd Gen) function server(europe-west1)...
Build failed with status: FAILURE and message: npm error code EBADPLATFORM
npm error notsup Unsupported platform for @css-inline/css-inline-win32-x64-msvc@0.14.1: wanted {"os":"win32","cpu":"x64"} (current: {"os":"linux","cpu":"x64"})
npm error notsup Valid os:   win32
npm error notsup Actual os:  linux
npm error notsup Valid cpu:  x64
npm error notsup Actual cpu: x64

If i replaced for win 32 per linux64 : "@css-inline/css-inline-win32-x64-msvc": "0.14.1" => "@css-inline/css-inline-linux-x64-gnu": "0.14.1", "@resvg/resvg-js-win32-x64-msvc": "2.6.2",=> "@resvg/resvg-js-linux-x64-gnu": "2.6.2", this results in "npm install" failing on my machine (should not it take account the nitro for Firebase environment instead?)

Theses errors stop the deployment. Do i need to open another issue? Also similar to https://github.com/nuxt/nuxt/issues/21393 and https://github.com/nuxt/nuxt/issues/26735