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

tylernathanreed's avatar

require('js') returns empty object

I'm working with some of the node.js functionalities within Laravel, namely using laravel-mix, and I'm encountering a problem with my source code.

For whatever reason, require('fs') is returning an empty object, essentially preventing me from using the module.

I've already tried adding fs: 'empty' to my webpack configuration:

let mix = require('laravel-mix');

mix.webpackConfig({
    node: {
        fs: 'empty'
    }
});

mix.js('resources/assets/js/app.js', 'public/js')
   .sass('resources/assets/sass/app.scss', 'public/css')
   .sourceMaps();

Which didn't solve the problem.

I'm using Windows 10 right now, and I tried running it on Windows 7 this morning. Neither of which worked.

Is there something I'm doing wrong?

0 likes
2 replies
Borisu's avatar

A silly question, but did you run npm install?

tylernathanreed's avatar

Yes, of course.

I'm on the latest LTS for Node.js and npm. I've also been running npm run watch without issues (other than the fs issue I've described here).

Please or to participate in this conversation.