Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

fmalsalamah's avatar

Laravel mix: Installing firebase-admin dependency modules were not found

I'm trying to install firebase-admin found in https://www.npmjs.com/package/firebase-admin using npm install --save firebase-admin

now when I do :require('firebase-admin'); and run: npm run dev

The following error appears:

These modules were not found:
* fs in ./~/firebase-admin/lib/auth/credential.js, ./~/request/lib/har.js
* net in ./~/firebase-admin/~/faye-websocket/lib/faye/websocket/client.js, ./~/forever-agent/index.js and 3 others
* tls in ./~/firebase-admin/~/faye-websocket/lib/faye/websocket/client.js, ./~/forever-agent/index.js and 1 other
* dns in ./~/firebase-admin/~/isemail/lib/isemail.js 

webpack.mix.js:

const { mix } = require('laravel-mix');

/*
 |--------------------------------------------------------------------------
 | Mix Asset Management
 |--------------------------------------------------------------------------
 |
 | Mix provides a clean, fluent API for defining some Webpack build steps
 | for your Laravel application. By default, we are compiling the Sass
 | file for the application as well as bundling up all the JS files.
 |
 */

mix.js(['resources/assets/js/app.js',
        'resources/assets/js/main.js'], 'public/js')
   .sass('resources/assets/sass/app.scss', 'public/css');`

main.js

import * as admin from "firebase-admin";
0 likes
2 replies
ejdelmonico's avatar

You probably need to make an alias for firebase-admin or make it know via:

plugins: [
    new webpack.loaderOptionsPlugin({
        options: {
            includePaths: [
                path.resolve(__dirname, './node_modules/firebase-admin/')
            ]
        }
    })
]
fmalsalamah's avatar

Thanks for responding, I have added the option as follows but with no luck.

module.exports.plugins = (module.exports.plugins || []).concat([
    new webpack.ProvidePlugin(Mix.autoload || {
        jQuery: 'jquery',
        $: 'jquery',
        jquery: 'jquery'
    }),

    new plugins.FriendlyErrorsWebpackPlugin(),

    new plugins.StatsWriterPlugin({
        filename: 'mix-manifest.json',
        transform: Mix.manifest.transform.bind(Mix.manifest),
    }),

    new plugins.WebpackMd5HashPlugin(),

    new webpack.LoaderOptionsPlugin({
        minimize: Mix.inProduction,
        options: {
            postcss: Mix.options.postCss,
            context: __dirname,
            output: { path: './' },
            includePaths: [
                path.resolve(__dirname, './node_modules/firebase-admin/')
            ]
        }
    })
]);

Please or to participate in this conversation.