Branch builds but "Cannot find module buffer" on opening

We are trying to translate our front collection to use Brunch. Here's the Brunch config I have so far:

module.exports = {

  files: {
    javascripts: {
      joinTo: {
        'vendor.js': /^(?!source)/,
        'app.js': /^source/
      },
      entryPoints: {
        'source/scripts/app.jsx': 'app.js'
      }
    },
    stylesheets: {joinTo: 'core.css'},
  },

  paths: {
    watched: ['source']
  },

  modules: {
    autoRequire: {
      'app.js': ['source/scripts/app']
    }
  },

  plugins: {
    babel: {presets: ['latest', 'react']},
    postcss: {processors: [require('autoprefixer')]},
    assetsmanager: {
      copyTo: {
        'assets': ['source/resources/*']
      }
    },
    static: {
      processors: [
        require('html-brunch-static')({
          processors: [
            require('pug-brunch-static')({
              fileMatch: 'source/views/home.pug',
              fileTransform: (filename) => {
                filename = filename.replace(/\.pug$/, '.html');
                filename = filename.replace('views/', '');
                return filename;
              }
            })
          ]
        })
      ]
    }

  }

};

      

I added a section modules.autoRequire

to the Brunch config, after which the following error occurred. Without modules.autoRequire

I have no console error, but my web app won't start either. Launching brunch build

does not fail, but when I open the embedded website I get the error

Unused error: Cannot find module 'buffer' from 'lodash / lodash.js'

The first line in the stacktrace points me to this function in vendor.js

var require = function(name, loaderPath) {
  if (loaderPath == null) loaderPath = '/';
  var path = expandAlias(name);

  if (has.call(cache, path)) return cache[path].exports;
  if (has.call(modules, path)) return initModule(path, modules[path]);

  throw new Error("Cannot find module '" + name + "' from '" + loaderPath + "'");
};

      

I'm not sure how to get started with my work. This issue seems like it might be relevant.

How can I overcome this error? (Please feel free to ask for more information. I'm not sure if this will be helpful.)

+3


source to share


1 answer


Brunch runs the build pipeline steps from (nunch packages) npm packages defined in package.json

. Therefore, be sure to include all required packages (or remove unnecessary ones).



See the docs for more information on how to use plugins .

+1


source







All Articles