firebase / firebase-tools

The Firebase Command Line Tools
MIT License
4.01k stars 929 forks source link

Firebase init fails on arm mac #7024

Open FrivalszkyP opened 5 months ago

FrivalszkyP commented 5 months ago

[REQUIRED] Environment info

firebase --version: 13.7.3

Platform:

macOS: M1 Sonoma Latest npm, pnpm, bun, all of these produce the same issue. Optional dependencies are allowed by default.

[REQUIRED] Test case

Hey folks, I'm running into an issue with my svelte application, although the issue could be related to vite rather than svelte itself. While the application builds successfully, the firebase init command produces an error that seems to have something to do with a rollup dependency missing. The rollup dependency is for darwin architecture but that's not what my platform is using.

See @Startouf's comment here, it describes the same issue.

[REQUIRED] Steps to reproduce

[REQUIRED] Expected behavior

Firebase command succeeds.

[REQUIRED] Actual behavior

[debug] [2024-04-20T15:23:34.001Z] Error: Cannot find module @rollup/rollup-darwin-x64. npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). Please try `npm i` again after removing both package-lock.json and node_modules directory.
    at requireWithFriendlyError (/Users/freevo/freevo/svelte-5/node_modules/rollup/dist/native.js:59:9)
    at Object.<anonymous> (/Users/freevo/freevo/svelte-5/node_modules/rollup/dist/native.js:68:76)
    at Module._compile (node:internal/modules/cjs/loader:1112:14)
    at Module._compile (pkg/prelude/bootstrap.js:1890:32)
    at Module._extensions..js (node:internal/modules/cjs/loader:1166:10)
    at Module.load (node:internal/modules/cjs/loader:988:32)
    at Module._load (node:internal/modules/cjs/loader:834:12)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:170:29)
    at ModuleJob.run (node:internal/modules/esm/module_job:198:25)
    at async Promise.all (index 0)
[error] 
[error] Error: An unexpected error has occurred.
karocksjoelee commented 3 months ago

... Any progress on this ?

CxrlosKenobi commented 3 months ago

I had the same issue on my Macbook Air M1 running firebase init for an Angular 18 project built with yarn.

I managed to solve it by examining any global packages that might be interfering. Sometimes, global installations can cause conflicts or issues, especially with CLI tools like Firebase.

npm list -g --depth=0

And I went through each of my project-related packages checking and updating to the latest version on npm, like:

npm install -g firebase-tools@latest
npm install -g tsx@latest
npm install -g npm@latest
...

Finally I cleaned up my project by removing node_modules and yarn.lock file to ensure that it takes the latest updates. Working so far to set up my firebase init hosting 💯