firebase / firebase/firebase-admin-node
Firebase: Module not found: Can't resolve 'fs' needed an alteration
- Vorherrschende Sprache
- TypeScript
- Sterne
- 1.7k
- Forks
- 419
- Ø Merge
- 3 T. 10 Std.
- Gemergte PRs (30 T.)
- 16
Beschreibung
### [REQUIRED] Step 2: Describe your environment
* Operating System version: Windows 10
* Firebase SDK version: `"firebase": "^9.15.0",`
* Firebase Product: General
* Node.js version: `v16.15.1`
* NPM version: `8.11.0`
* Firebase Admin version: `"firebase-admin": "^11.4.1",`
* NextJS version: `"next": "13.1.2",`
* React version: `"react": "18.2.0",`
### [REQUIRED] Step 3: Describe the problem
1. Download Firebase admin: `npm install firebase-admin`
1. Start locally: `npm run dev`
I get an error:
```
error - ./node_modules/@google-cloud/storage/build/src/bucket.js:21:0 Module not found: Can't resolve 'fs'
```
I am able to resolve this issue by adding this snippet to my `next.config.js` file:
```js
/** @type {import('next').NextConfig} */
const nextConfig = {
future: {
webpack5: true, // by default, if you customize webpack config, they switch back to version 4.
// Looks like backward compatibility approach.
},
webpack(config) {
config.resolve.fallback = {
...config.resolve.fallback, // if you miss it, all the other options in fallback, specified
// by next.js will be dropped. Doesn't make much sense, but how it is
fs: false, // the solution
}
return config
},
}
module.exports = nextConfig
```
The error was resolved BUT I would expect this dependency to work without having to alter my configuration in NextJS since this is a common framework. Is there a way to fix this to not have to alter my configuration?
fec57f57-44e2-44dd-832b-ac37a20c5739
Beitragsleitfaden
Rechercherichtung
Beginne damit, den gemeldeten Fehler mit Firebase Admin, Next.js und den aufgeführten npm-Versionen mithilfe von `npm run dev` zu reproduzieren. Untersuche den generierten Fehler in `node_modules/@google-cloud/storage/build/src/bucket.js` und vergleiche ihn mit dem Workaround in `next.config.js`; abgeschlossen ist die Aufgabe, wenn festgestellt wurde, ob die SDK- oder die Framework-Konfiguration geändert werden sollte, und überprüft wurde, dass der Fehler ohne diesen Workaround nicht mehr auftritt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- firebase, nextjs, nodejs, typescript
- Bereich
- backend, build-system, web-dev
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 30/100