Support Forums

Esbuild error with netlify build


I’m getting a following error when trying to build my Next.js app with netlify-cli with esbuild set:

> node_modules/xxx/build/node_modules/recompose/withPropsOnChange.js:15:39: error: No loader is configured for ".js_commonjs-proxy" files: node_modules/xxx/build/_virtual/react-lifecycles-compat.es.js_commonjs-proxy
    15 │ ...at_es = require('../../_virtual/react-lifecycles-compat.es.js_commonjs-proxy')

What I have done:

  • Set target: ‘experimental-serverless-trace’ in next.config.js
  • Added following in netlify.toml:
  command = "npm run build"
  publish = "out"

  node_bundler = "esbuild"
  external_node_modules = [ "canvas", "jsdom", "next", "next-i18next", "@ampproject/toolbox-optimizer"]

  package = "@netlify/plugin-nextjs"

However I can’t add the the module which the error comes from to the external_node_modules or the app won’t work.

If I build the app like so I get no errors: next build && next export however I assume I have to use the ‘netlify-plugin-nextjs’ package to build the netlify functions for next.js

Can I add loaders to the esbuild or what should I do? Thanks!

Hi @joonassandell,

Just to test, does the same thing happen even when you use Git-based builds? Just wanted to confirm if it’s only local to CLI or the entire build system.