Error when adding a webpack plugin

default discord avatar
lynndylanhurley
7 months ago
1 2

Bug Report

I tried to add the webpack.EnviornmentPlugin. I'm unable to use the PAYLOAD_PUBLIC_ prefix because I need to access two env vars added by my hosting platform that don't follow that convention.

Here is the config I tried:

export default buildConfig({
  // ...
  admin: {
    // ...
    webpack: (config) => {
      const envPlugin = new webpack.EnvironmentPlugin({
        HEROKU_BRANCH: 'main',
        HEROKU_APP_NAME: 'my-app-name'
      });

      config.plugins = [envPlugin, ...config.plugins];

      return config;
    }
  },
  // ...

The app crashed with the following error:

cms:dev: webpack built 3fbf3f9bb7d011f70cd9 in 1419ms
cms:dev: WARNING in ../../node_modules/@swc/core/binding.js 12:28-61
cms:dev: Module not found: Error: Can't resolve 'child_process' in '/Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/@swc/core'
cms:dev: 
cms:dev: WARNING in ../../node_modules/@swc/core/binding.js 31:40-75
cms:dev: Module not found: Error: Can't resolve './swc.android-arm64.node' in '/Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/@swc/core'
cms:dev: 
cms:dev: WARNING in ../../node_modules/@swc/core/binding.js 34:40-74
cms:dev: Module not found: Error: Can't resolve '@swc/core-android-arm64' in '/Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/@swc/core'
cms:dev: 
cms:dev: WARNING in ../../node_modules/@swc/core/binding.js 45:40-78
cms:dev: Module not found: Error: Can't resolve './swc.android-arm-eabi.node' in '/Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/@swc/core'
cms:dev: 
cms:dev: WARNING in ../../node_modules/@swc/core/binding.js 48:40-77
cms:dev: Module not found: Error: Can't resolve '@swc/core-android-arm-eabi' in '/Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/@swc/core'
cms:dev: 
cms:dev: WARNING in ../../node_modules/@swc/core/binding.js 65:40-76
cms:dev: Module not found: Error: Can't resolve './swc.win32-x64-msvc.node' in '/Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/@swc/core'
cms:dev: 
cms:dev: WARNING in ../../node_modules/@swc/core/binding.js 68:40-75
cms:dev: Module not found: Error: Can't resolve '@swc/core-win32-x64-msvc' in '/Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/@swc/core'
cms:dev: 
cms:dev: WARNING in ../../node_modules/@swc/core/binding.js 79:40-77
cms:dev: Module not found: Error: Can't resolve './swc.win32-ia32-msvc.node' in '/Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/@swc/core'
cms:dev: 
cms:dev: WARNING in ../../node_modules/@swc/core/binding.js 82:40-76
cms:dev: Module not found: Error: Can't resolve '@swc/core-win32-ia32-msvc' in '/Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/@swc/core'
cms:dev: 
cms:dev: WARNING in ../../node_modules/@swc/core/binding.js 93:40-78
cms:dev: Module not found: Error: Can't resolve './swc.win32-arm64-msvc.node' in '/Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/@swc/core'
cms:dev: 
cms:dev: WARNING in ../../node_modules/@swc/core/binding.js 96:40-77
cms:dev: Module not found: Error: Can't resolve '@swc/core-win32-arm64-msvc' in '/Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/@swc/core'
cms:dev: 
cms:dev: WARNING in ../../node_modules/@swc/core/binding.js 113:40-72
cms:dev: Module not found: Error: Can't resolve './swc.darwin-x64.node' in '/Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/@swc/core'
cms:dev: 
cms:dev: WARNING in ../../node_modules/@swc/core/binding.js 116:40-71
cms:dev: Module not found: Error: Can't resolve '@swc/core-darwin-x64' in '/Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/@swc/core'
cms:dev: 
cms:dev: WARNING in ../../node_modules/@swc/core/binding.js 127:40-74
cms:dev: Module not found: Error: Can't resolve './swc.darwin-arm64.node' in '/Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/@swc/core'
cms:dev: 
cms:dev: WARNING in ../../node_modules/@swc/core/binding.js 148:32-65
cms:dev: Module not found: Error: Can't resolve './swc.freebsd-x64.node' in '/Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/@swc/core'
cms:dev: 
cms:dev: WARNING in ../../node_modules/@swc/core/binding.js 151:32-64
cms:dev: Module not found: Error: Can't resolve '@swc/core-freebsd-x64' in '/Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/@swc/core'
cms:dev: 
cms:dev: WARNING in ../../node_modules/@swc/core/binding.js 165:44-80
cms:dev: Module not found: Error: Can't resolve './swc.linux-x64-musl.node' in '/Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/@swc/core'
cms:dev: 
cms:dev: WARNING in ../../node_modules/@swc/core/binding.js 168:44-79
cms:dev: Module not found: Error: Can't resolve '@swc/core-linux-x64-musl' in '/Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/@swc/core'
cms:dev: 
cms:dev: WARNING in ../../node_modules/@swc/core/binding.js 179:44-79
cms:dev: Module not found: Error: Can't resolve './swc.linux-x64-gnu.node' in '/Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/@swc/core'
cms:dev: 
cms:dev: WARNING in ../../node_modules/@swc/core/binding.js 182:44-78
cms:dev: Module not found: Error: Can't resolve '@swc/core-linux-x64-gnu' in '/Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/@swc/core'
cms:dev: 
cms:dev: WARNING in ../../node_modules/@swc/core/binding.js 195:44-82
cms:dev: Module not found: Error: Can't resolve './swc.linux-arm64-musl.node' in '/Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/@swc/core'
cms:dev: 
cms:dev: WARNING in ../../node_modules/@swc/core/binding.js 198:44-81
cms:dev: Module not found: Error: Can't resolve '@swc/core-linux-arm64-musl' in '/Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/@swc/core'
cms:dev: 
cms:dev: WARNING in ../../node_modules/@swc/core/binding.js 209:44-81
cms:dev: Module not found: Error: Can't resolve './swc.linux-arm64-gnu.node' in '/Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/@swc/core'
cms:dev: 
cms:dev: WARNING in ../../node_modules/@swc/core/binding.js 212:44-80
cms:dev: Module not found: Error: Can't resolve '@swc/core-linux-arm64-gnu' in '/Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/@swc/core'
cms:dev: 
cms:dev: WARNING in ../../node_modules/@swc/core/binding.js 224:40-81
cms:dev: Module not found: Error: Can't resolve './swc.linux-arm-gnueabihf.node' in '/Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/@swc/core'
cms:dev: 
cms:dev: WARNING in ../../node_modules/@swc/core/binding.js 227:40-80
cms:dev: Module not found: Error: Can't resolve '@swc/core-linux-arm-gnueabihf' in '/Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/@swc/core'
cms:dev: 
cms:dev: WARNING in ../../node_modules/@swc/core/index.js 62:39-85
cms:dev: Critical dependency: the request of a dependency is an expression
cms:dev: 
cms:dev: WARNING in ../../node_modules/@swc/core/spack.js 42:33-46
cms:dev: Critical dependency: the request of a dependency is an expression
cms:dev: 
cms:dev: WARNING in ../../node_modules/esbuild/lib/main.js 1798:8-28
cms:dev: Critical dependency: the request of a dependency is an expression
cms:dev: 
cms:dev: WARNING in ../../node_modules/esbuild/lib/main.js 1865:15-32
cms:dev: Module not found: Error: Can't resolve 'pnpapi' in '/Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/esbuild/lib'
cms:dev: 
cms:dev: WARNING in ../../node_modules/esbuild/lib/main.js 1898:21-46
cms:dev: Module not found: Error: Can't resolve 'worker_threads' in '/Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/esbuild/lib'
cms:dev: 
cms:dev: WARNING in ../../node_modules/jest-worker/build/WorkerPool.js 22:4-29
cms:dev: Module not found: Error: Can't resolve 'worker_threads' in '/Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/jest-worker/build'
cms:dev: 
cms:dev: WARNING in ../../node_modules/jest-worker/build/base/BaseWorkerPool.js 111:19-46
cms:dev: Critical dependency: the request of a dependency is an expression
cms:dev: 
cms:dev: WARNING in ../../node_modules/jest-worker/build/index.js 68:19-38
cms:dev: Critical dependency: the request of a dependency is an expression
cms:dev: 
cms:dev: WARNING in ../../node_modules/jest-worker/build/workers/processChild.js 89:15-28
cms:dev: Critical dependency: the request of a dependency is an expression
cms:dev: 
cms:dev: WARNING in ../../node_modules/jest-worker/build/workers/processChild.js 105:15-28
cms:dev: Critical dependency: the request of a dependency is an expression
cms:dev: 
cms:dev: WARNING in ../../node_modules/loader-runner/lib/loadLoader.js 7:31-45
cms:dev: Module not found: Error: Can't resolve 'url' in '/Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/loader-runner/lib'
cms:dev: 
cms:dev: BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
cms:dev: This is no longer the case. Verify if you need this module and configure a polyfill for it.
cms:dev: 
cms:dev: If you want to include a polyfill, you need to:
cms:dev:         - add a fallback 'resolve.fallback: { "url": require.resolve("url/") }'
cms:dev:         - install 'url'
cms:dev: If you don't want to include a polyfill, you can use an empty module like this:
cms:dev:         resolve.fallback: { "url": false }
cms:dev: 
cms:dev: WARNING in ../../node_modules/loader-runner/lib/loadLoader.js 19:16-36
cms:dev: Critical dependency: the request of a dependency is an expression
cms:dev: 
cms:dev: WARNING in ../../node_modules/terser-webpack-plugin/dist/minify.js 43:118-125
cms:dev: Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
cms:dev: 
cms:dev: WARNING in ../../node_modules/webpack/lib/debug/ProfilingPlugin.js 26:13-33
cms:dev: Module not found: Error: Can't resolve 'inspector' in '/Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/webpack/lib/debug'
cms:dev: 
cms:dev: WARNING in ../../node_modules/webpack/lib/serialization/ObjectMiddleware.js 647:9-25
cms:dev: Critical dependency: the request of a dependency is an expression
cms:dev: 
cms:dev: ERROR in ../../node_modules/@swc/core-darwin-arm64/swc.darwin-arm64.node 1:0
cms:dev: Module parse failed: Unexpected character '�' (1:0)
cms:dev: You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
cms:dev: (Source code omitted for this binary file)
cms:dev: 
cms:dev: ERROR in ../../node_modules/@swc/core/binding.js 2:37-50
cms:dev: Module not found: Error: Can't resolve 'fs' in '/Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/@swc/core'
cms:dev: 
cms:dev: ERROR in ../../node_modules/@swc/core/index.js 70:27-47
cms:dev: Module not found: Error: Can't resolve '@swc/wasm' in '/Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/@swc/core'
cms:dev: 
cms:dev: ERROR in ../../node_modules/chrome-trace-event/dist/trace-event.js 10:17-34
cms:dev: Module not found: Error: Can't resolve 'stream' in '/Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/chrome-trace-event/dist'
cms:dev: 
cms:dev: BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
cms:dev: This is no longer the case. Verify if you need this module and configure a polyfill for it.
cms:dev: 
cms:dev: If you want to include a polyfill, you need to:
cms:dev:         - add a fallback 'resolve.fallback: { "stream": require.resolve("stream-browserify") }'
cms:dev:         - install 'stream-browserify'
cms:dev: If you don't want to include a polyfill, you can use an empty module like this:
cms:dev:         resolve.fallback: { "stream": false }
cms:dev: 
cms:dev: ERROR in ../../node_modules/esbuild/lib/main.d.ts 1:7
cms:dev: Module parse failed: Unexpected token (1:7)
cms:dev: You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
cms:dev: > export type Platform = 'browser' | 'node' | 'neutral';
cms:dev: | export type Format = 'iife' | 'cjs' | 'esm';
cms:dev: | export type Loader = 'base64' | 'binary' | 'copy' | 'css' | 'dataurl' | 'default' | 'empty' | 'file' | 'js' | 'json' | 'jsx' | 'text' | 'ts' | 'tsx';
cms:dev: 
cms:dev: ERROR in ../../node_modules/esbuild/lib/main.js 1701:9-22
cms:dev: Module not found: Error: Can't resolve 'fs' in '/Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/esbuild/lib'
cms:dev: 
cms:dev: ERROR in ../../node_modules/esbuild/lib/main.js 1702:9-22
cms:dev: Module not found: Error: Can't resolve 'os' in '/Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/esbuild/lib'
cms:dev: 
cms:dev: BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
cms:dev: This is no longer the case. Verify if you need this module and configure a polyfill for it.
cms:dev: 
cms:dev: If you want to include a polyfill, you need to:
cms:dev:         - add a fallback 'resolve.fallback: { "os": require.resolve("os-browserify/browser") }'
cms:dev:         - install 'os-browserify'
cms:dev: If you don't want to include a polyfill, you can use an empty module like this:
cms:dev:         resolve.fallback: { "os": false }
cms:dev: 
cms:dev: ERROR in ../../node_modules/esbuild/lib/main.js 1889:20-44
cms:dev: Module not found: Error: Can't resolve 'child_process' in '/Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/esbuild/lib'
cms:dev: 
cms:dev: ERROR in ../../node_modules/esbuild/lib/main.js 1894:10-24
cms:dev: Module not found: Error: Can't resolve 'tty' in '/Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/esbuild/lib'
cms:dev: 
cms:dev: BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
cms:dev: This is no longer the case. Verify if you need this module and configure a polyfill for it.
cms:dev: 
cms:dev: If you want to include a polyfill, you need to:
cms:dev:         - add a fallback 'resolve.fallback: { "tty": require.resolve("tty-browserify") }'
cms:dev:         - install 'tty-browserify'
cms:dev: If you don't want to include a polyfill, you can use an empty module like this:
cms:dev:         resolve.fallback: { "tty": false }
cms:dev: 
cms:dev: ERROR in ../../node_modules/graceful-fs/graceful-fs.js 1:9-22
cms:dev: Module not found: Error: Can't resolve 'fs' in '/Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/graceful-fs'
cms:dev: 
cms:dev: ERROR in ../../node_modules/graceful-fs/legacy-streams.js 1:13-37
cms:dev: Module not found: Error: Can't resolve 'stream' in '/Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/graceful-fs'
cms:dev: 
cms:dev: BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
cms:dev: This is no longer the case. Verify if you need this module and configure a polyfill for it.
cms:dev: 
cms:dev: If you want to include a polyfill, you need to:
cms:dev:         - add a fallback 'resolve.fallback: { "stream": require.resolve("stream-browserify") }'
cms:dev:         - install 'stream-browserify'
cms:dev: If you don't want to include a polyfill, you can use an empty module like this:
cms:dev:         resolve.fallback: { "stream": false }
cms:dev: 
cms:dev: ERROR in ../../node_modules/graceful-fs/polyfills.js 1:16-36
cms:dev: Module not found: Error: Can't resolve 'constants' in '/Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/graceful-fs'
cms:dev: 
cms:dev: BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
cms:dev: This is no longer the case. Verify if you need this module and configure a polyfill for it.
cms:dev: 
cms:dev: If you want to include a polyfill, you need to:
cms:dev:         - add a fallback 'resolve.fallback: { "constants": require.resolve("constants-browserify") }'
cms:dev:         - install 'constants-browserify'
cms:dev: If you don't want to include a polyfill, you can use an empty module like this:
cms:dev:         resolve.fallback: { "constants": false }
cms:dev: 
cms:dev: ERROR in ../../node_modules/jest-worker/build/index.js 27:15-28
cms:dev: Module not found: Error: Can't resolve 'os' in '/Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/jest-worker/build'
cms:dev: 
cms:dev: BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
cms:dev: This is no longer the case. Verify if you need this module and configure a polyfill for it.
cms:dev: 
cms:dev: If you want to include a polyfill, you need to:
cms:dev:         - add a fallback 'resolve.fallback: { "os": require.resolve("os-browserify/browser") }'
cms:dev:         - install 'os-browserify'
cms:dev: If you don't want to include a polyfill, you can use an empty module like this:
cms:dev:         resolve.fallback: { "os": false }
cms:dev: 
cms:dev: ERROR in ../../node_modules/jest-worker/build/workers/ChildProcessWorker.js 9:15-39
cms:dev: Module not found: Error: Can't resolve 'child_process' in '/Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/jest-worker/build/workers'
cms:dev: 
cms:dev: ERROR in ../../node_modules/jest-worker/build/workers/ChildProcessWorker.js 19:15-32
cms:dev: Module not found: Error: Can't resolve 'stream' in '/Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/jest-worker/build/workers'
cms:dev: 
cms:dev: BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
cms:dev: This is no longer the case. Verify if you need this module and configure a polyfill for it.
cms:dev: 
cms:dev: If you want to include a polyfill, you need to:
cms:dev:         - add a fallback 'resolve.fallback: { "stream": require.resolve("stream-browserify") }'
cms:dev:         - install 'stream-browserify'
cms:dev: If you don't want to include a polyfill, you can use an empty module like this:
cms:dev:         resolve.fallback: { "stream": false }
cms:dev: 
cms:dev: ERROR in ../../node_modules/jest-worker/build/workers/NodeThreadsWorker.js 19:15-32
cms:dev: Module not found: Error: Can't resolve 'stream' in '/Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/jest-worker/build/workers'
cms:dev: 
cms:dev: BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
cms:dev: This is no longer the case. Verify if you need this module and configure a polyfill for it.
cms:dev: 
cms:dev: If you want to include a polyfill, you need to:
cms:dev:         - add a fallback 'resolve.fallback: { "stream": require.resolve("stream-browserify") }'
cms:dev:         - install 'stream-browserify'
cms:dev: If you don't want to include a polyfill, you can use an empty module like this:
cms:dev:         resolve.fallback: { "stream": false }
cms:dev: 
cms:dev: ERROR in ../../node_modules/jest-worker/build/workers/NodeThreadsWorker.js 29:15-40
cms:dev: Module not found: Error: Can't resolve 'worker_threads' in '/Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/jest-worker/build/workers'
cms:dev: 
cms:dev: ERROR in ../../node_modules/jest-worker/build/workers/messageParent.js 19:39-64
cms:dev: Module not found: Error: Can't resolve 'worker_threads' in '/Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/jest-worker/build/workers'
cms:dev: 
cms:dev: ERROR in ../../node_modules/loader-runner/lib/LoaderRunner.js 5:9-22
cms:dev: Module not found: Error: Can't resolve 'fs' in '/Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/loader-runner/lib'
cms:dev: 
cms:dev: ERROR in ../../node_modules/merge-stream/index.js 3:24-41
cms:dev: Module not found: Error: Can't resolve 'stream' in '/Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/merge-stream'
cms:dev: 
cms:dev: BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
cms:dev: This is no longer the case. Verify if you need this module and configure a polyfill for it.
cms:dev: 
cms:dev: If you want to include a polyfill, you need to:
cms:dev:         - add a fallback 'resolve.fallback: { "stream": require.resolve("stream-browserify") }'
cms:dev:         - install 'stream-browserify'
cms:dev: If you don't want to include a polyfill, you can use an empty module like this:
cms:dev:         resolve.fallback: { "stream": false }
cms:dev: 
cms:dev: ERROR in ../../node_modules/terser-webpack-plugin/dist/index.js 5:11-24
cms:dev: Module not found: Error: Can't resolve 'os' in '/Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/terser-webpack-plugin/dist'
cms:dev: 
cms:dev: BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
cms:dev: This is no longer the case. Verify if you need this module and configure a polyfill for it.
cms:dev: 
cms:dev: If you want to include a polyfill, you need to:
cms:dev:         - add a fallback 'resolve.fallback: { "os": require.resolve("os-browserify/browser") }'
cms:dev:         - install 'os-browserify'
cms:dev: If you don't want to include a polyfill, you can use an empty module like this:
cms:dev:         resolve.fallback: { "os": false }
cms:dev: 
cms:dev: ERROR in ../../node_modules/uglify-js/tools/node.js 1:9-22
cms:dev: Module not found: Error: Can't resolve 'fs' in '/Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/uglify-js/tools'
cms:dev: 
cms:dev: ERROR in ../../node_modules/watchpack/lib/DirectoryWatcher.js 17:15-37
cms:dev: Module not found: Error: Can't resolve 'os' in '/Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/watchpack/lib'
cms:dev: 
cms:dev: BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
cms:dev: This is no longer the case. Verify if you need this module and configure a polyfill for it.
cms:dev: 
cms:dev: If you want to include a polyfill, you need to:
cms:dev:         - add a fallback 'resolve.fallback: { "os": require.resolve("os-browserify/browser") }'
cms:dev:         - install 'os-browserify'
cms:dev: If you don't want to include a polyfill, you can use an empty module like this:
cms:dev:         resolve.fallback: { "os": false }
cms:dev: 
cms:dev: ERROR in ../../node_modules/watchpack/lib/LinkResolver.js 7:11-24
cms:dev: Module not found: Error: Can't resolve 'fs' in '/Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/watchpack/lib'
cms:dev: 
cms:dev: ERROR in ../../node_modules/watchpack/lib/watchEventSource.js 7:11-24
cms:dev: Module not found: Error: Can't resolve 'fs' in '/Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/watchpack/lib'
cms:dev: 
cms:dev: ERROR in ../../node_modules/watchpack/lib/watchEventSource.js 12:15-37
cms:dev: Module not found: Error: Can't resolve 'os' in '/Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/watchpack/lib'
cms:dev: 
cms:dev: BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
cms:dev: This is no longer the case. Verify if you need this module and configure a polyfill for it.
cms:dev: 
cms:dev: If you want to include a polyfill, you need to:
cms:dev:         - add a fallback 'resolve.fallback: { "os": require.resolve("os-browserify/browser") }'
cms:dev:         - install 'os-browserify'
cms:dev: If you don't want to include a polyfill, you can use an empty module like this:
cms:dev:         resolve.fallback: { "os": false }
cms:dev: 
cms:dev: ERROR in ../../node_modules/webpack/lib/FileSystemInfo.js 9:19-36
cms:dev: Module not found: Error: Can't resolve 'module' in '/Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/webpack/lib'
cms:dev: Did you mean './module'?
cms:dev: Requests that should resolve in the current directory need to start with './'.
cms:dev: Requests that start with a name are treated as module requests and resolve within module directories (node_modules, /Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/payload/node_modules).
cms:dev: If changing the source code is not an option there is also a resolve options called 'preferRelative' which tries to resolve these kind of requests in the current directory too.
cms:dev: 
cms:dev: ERROR in ../../node_modules/webpack/lib/NormalModule.js 10:20-42
cms:dev: Module not found: Error: Can't resolve 'querystring' in '/Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/webpack/lib'
cms:dev: 
cms:dev: BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
cms:dev: This is no longer the case. Verify if you need this module and configure a polyfill for it.
cms:dev: 
cms:dev: If you want to include a polyfill, you need to:
cms:dev:         - add a fallback 'resolve.fallback: { "querystring": require.resolve("querystring-es3") }'
cms:dev:         - install 'querystring-es3'
cms:dev: If you don't want to include a polyfill, you can use an empty module like this:
cms:dev:         resolve.fallback: { "querystring": false }
cms:dev: 
cms:dev: ERROR in ../../node_modules/webpack/lib/config/defaults.js 8:11-24
cms:dev: Module not found: Error: Can't resolve 'fs' in '/Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/webpack/lib/config'
cms:dev: 
cms:dev: ERROR in ../../node_modules/webpack/lib/dependencies/CommonJsImportsParserPlugin.js 8:26-40
cms:dev: Module not found: Error: Can't resolve 'url' in '/Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/webpack/lib/dependencies'
cms:dev: 
cms:dev: BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
cms:dev: This is no longer the case. Verify if you need this module and configure a polyfill for it.
cms:dev: 
cms:dev: If you want to include a polyfill, you need to:
cms:dev:         - add a fallback 'resolve.fallback: { "url": require.resolve("url/") }'
cms:dev:         - install 'url'
cms:dev: If you don't want to include a polyfill, you can use an empty module like this:
cms:dev:         resolve.fallback: { "url": false }
cms:dev: 
cms:dev: ERROR in ../../node_modules/webpack/lib/dependencies/ImportMetaPlugin.js 8:26-40
cms:dev: Module not found: Error: Can't resolve 'url' in '/Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/webpack/lib/dependencies'
cms:dev: 
cms:dev: BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
cms:dev: This is no longer the case. Verify if you need this module and configure a polyfill for it.
cms:dev: 
cms:dev: If you want to include a polyfill, you need to:
cms:dev:         - add a fallback 'resolve.fallback: { "url": require.resolve("url/") }'
cms:dev:         - install 'url'
cms:dev: If you don't want to include a polyfill, you can use an empty module like this:
cms:dev:         resolve.fallback: { "url": false }
cms:dev: 
cms:dev: ERROR in ../../node_modules/webpack/lib/dependencies/URLPlugin.js 8:26-40
cms:dev: Module not found: Error: Can't resolve 'url' in '/Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/webpack/lib/dependencies'
cms:dev: 
cms:dev: BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
cms:dev: This is no longer the case. Verify if you need this module and configure a polyfill for it.
cms:dev: 
cms:dev: If you want to include a polyfill, you need to:
cms:dev:         - add a fallback 'resolve.fallback: { "url": require.resolve("url/") }'
cms:dev:         - install 'url'
cms:dev: If you don't want to include a polyfill, you can use an empty module like this:
cms:dev:         resolve.fallback: { "url": false }
cms:dev: 
cms:dev: ERROR in ../../node_modules/webpack/lib/dependencies/WorkerPlugin.js 8:26-40
cms:dev: Module not found: Error: Can't resolve 'url' in '/Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/webpack/lib/dependencies'
cms:dev: 
cms:dev: BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
cms:dev: This is no longer the case. Verify if you need this module and configure a polyfill for it.
cms:dev: 
cms:dev: If you want to include a polyfill, you need to:
cms:dev:         - add a fallback 'resolve.fallback: { "url": require.resolve("url/") }'
cms:dev:         - install 'url'
cms:dev: If you don't want to include a polyfill, you can use an empty module like this:
cms:dev:         resolve.fallback: { "url": false }
cms:dev: 
cms:dev: ERROR in ../../node_modules/webpack/lib/javascript/JavascriptModulesPlugin.js 9:11-24
cms:dev: Module not found: Error: Can't resolve 'vm' in '/Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/webpack/lib/javascript'
cms:dev: 
cms:dev: BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
cms:dev: This is no longer the case. Verify if you need this module and configure a polyfill for it.
cms:dev: 
cms:dev: If you want to include a polyfill, you need to:
cms:dev:         - add a fallback 'resolve.fallback: { "vm": require.resolve("vm-browserify") }'
cms:dev:         - install 'vm-browserify'
cms:dev: If you don't want to include a polyfill, you can use an empty module like this:
cms:dev:         resolve.fallback: { "vm": false }
cms:dev: 
cms:dev: ERROR in ../../node_modules/webpack/lib/javascript/JavascriptParser.js 11:11-24
cms:dev: Module not found: Error: Can't resolve 'vm' in '/Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/webpack/lib/javascript'
cms:dev: 
cms:dev: BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
cms:dev: This is no longer the case. Verify if you need this module and configure a polyfill for it.
cms:dev: 
cms:dev: If you want to include a polyfill, you need to:
cms:dev:         - add a fallback 'resolve.fallback: { "vm": require.resolve("vm-browserify") }'
cms:dev:         - install 'vm-browserify'
cms:dev: If you don't want to include a polyfill, you can use an empty module like this:
cms:dev:         resolve.fallback: { "vm": false }
cms:dev: 
cms:dev: ERROR in ../../node_modules/webpack/lib/schemes/FileUriPlugin.js 8:31-45
cms:dev: Module not found: Error: Can't resolve 'url' in '/Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/webpack/lib/schemes'
cms:dev: 
cms:dev: BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
cms:dev: This is no longer the case. Verify if you need this module and configure a polyfill for it.
cms:dev: 
cms:dev: If you want to include a polyfill, you need to:
cms:dev:         - add a fallback 'resolve.fallback: { "url": require.resolve("url/") }'
cms:dev:         - install 'url'
cms:dev: If you don't want to include a polyfill, you can use an empty module like this:
cms:dev:         resolve.fallback: { "url": false }
cms:dev: 
cms:dev: ERROR in ../../node_modules/webpack/lib/schemes/HttpUriPlugin.js 10:16-30
cms:dev: Module not found: Error: Can't resolve 'url' in '/Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/webpack/lib/schemes'
cms:dev: 
cms:dev: BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
cms:dev: This is no longer the case. Verify if you need this module and configure a polyfill for it.
cms:dev: 
cms:dev: If you want to include a polyfill, you need to:
cms:dev:         - add a fallback 'resolve.fallback: { "url": require.resolve("url/") }'
cms:dev:         - install 'url'
cms:dev: If you don't want to include a polyfill, you can use an empty module like this:
cms:dev:         resolve.fallback: { "url": false }
cms:dev: 
cms:dev: ERROR in ../../node_modules/webpack/lib/schemes/HttpUriPlugin.js 11:64-79
cms:dev: Module not found: Error: Can't resolve 'zlib' in '/Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/webpack/lib/schemes'
cms:dev: 
cms:dev: BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
cms:dev: This is no longer the case. Verify if you need this module and configure a polyfill for it.
cms:dev: 
cms:dev: If you want to include a polyfill, you need to:
cms:dev:         - add a fallback 'resolve.fallback: { "zlib": require.resolve("browserify-zlib") }'
cms:dev:         - install 'browserify-zlib'
cms:dev: If you don't want to include a polyfill, you can use an empty module like this:
cms:dev:         resolve.fallback: { "zlib": false }
cms:dev: 
cms:dev: ERROR in ../../node_modules/webpack/lib/serialization/FileMiddleware.js 8:21-38
cms:dev: Module not found: Error: Can't resolve 'stream' in '/Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/webpack/lib/serialization'
cms:dev: 
cms:dev: BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
cms:dev: This is no longer the case. Verify if you need this module and configure a polyfill for it.
cms:dev: 
cms:dev: If you want to include a polyfill, you need to:
cms:dev:         - add a fallback 'resolve.fallback: { "stream": require.resolve("stream-browserify") }'
cms:dev:         - install 'stream-browserify'
cms:dev: If you don't want to include a polyfill, you can use an empty module like this:
cms:dev:         resolve.fallback: { "stream": false }
cms:dev: 
cms:dev: ERROR in ../../node_modules/webpack/lib/serialization/FileMiddleware.js 15:4-19
cms:dev: Module not found: Error: Can't resolve 'zlib' in '/Users/lynn/Code/SomeOddPilot/superplastic-next/node_modules/webpack/lib/serialization'
cms:dev: 
cms:dev: BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
cms:dev: This is no longer the case. Verify if you need this module and configure a polyfill for it.
cms:dev: 
cms:dev: If you want to include a polyfill, you need to:
cms:dev:         - add a fallback 'resolve.fallback: { "zlib": require.resolve("browserify-zlib") }'
cms:dev:         - install 'browserify-zlib'
cms:dev: If you don't want to include a polyfill, you can use an empty module like this:
cms:dev:         resolve.fallback: { "zlib": false }
  • discord user avatar
    jmikrut
    Payload Team
    7 months ago

    Hey @lynndylanhurley — this is actually because the Webpack plugin you're using relies on some Node-only modules. But - - the Payload config is executed in both Node and in your browser, which is where all of these errors are coming from. You need to use a Webpack alias to tell Webpack to ignore that package for its browser JS, which will allow you to circumvent this issue.

    See more in our docs here:
    https://payloadcms.com/docs/admin/webpack#aliasing-server-only-modules

    I will convert this to a discussion but am happy to continue to help!

    2 replies
  • default discord avatar
    lynndylanhurley
    7 months ago

    Thanks @jmikrut ! I'll try this ASAP

  • default discord avatar
    lynndylanhurley
    6 months ago

    For anyone with this problem, this config is working for me:

    import { buildConfig } from 'payload/config';
    import webpack from 'webpack';
    import dotenv from 'dotenv';
    import path from 'path';
    // ...
    
    const mockModulePath = path.resolve(__dirname, 'mocks/emptyObject');
    
    dotenv.config({ path: __dirname + '/../../../.env' });
    
    export default buildConfig({
      // ...
      admin: {
        // ...
        webpack: (config) => {
          const envPlugin = new webpack.EnvironmentPlugin([
            'CMS_PORT',
            'NEXT_JS_PORT',
            'HEROKU_BRANCH',
            'HEROKU_APP_NAME'
          ]);
    
          config.plugins.unshift(envPlugin);
    
          config.resolve.alias = {
            ...config.resolve.alias,
            webpack: mockModulePath
          };
          return config;
        }
      },
      // ....
    });
  • default discord avatar
    leesei
    4 months ago

    Is using fallback (resolve: { fallback: { [module]: false } }) an easier solution? It works for node's builtins as I tried.
    See #910

Open the post
Continue the discussion in GitHub
Like what we're doing?
Star us on GitHub!

Star

Connect with the Payload Community on Discord

Discord

online

Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.