Getting this error when running dev server on Payload 2.0:
ERROR in ./src/payload.config.ts 130:0-28
Module not found: Error: Can't resolve 'dotenv' in '/Users/tyteen4a03/Documents/CodeProjects/Crisis/christmas-js/apps/backend/src'
webpack compiled with 1 error and 1 warning
Watchpack Error (watcher): Error: ENOTDIR: not a directory, watch '/Users/tyteen4a03/Documents/CodeProjects/Crisis/christmas-js/node_modules/@payloadcms/bundler-webpack/dist/mocks/emptyModule.js/mocks'
Watchpack Error (initial scan): Error: ENOTDIR: not a directory, scandir '/Users/tyteen4a03/Documents/CodeProjects/Crisis/christmas-js/node_modules/@payloadcms/bundler-webpack/dist/mocks/emptyModule.js/mocks'
Watchpack Error (initial scan): Error: ENOTDIR: not a directory, scandir '/Users/tyteen4a03/Documents/CodeProjects/Crisis/christmas-js/node_modules/@payloadcms/bundler-webpack/dist/mocks/emptyModule.js'
a workaround for now would be to provide your own dotenv alias
we have it aliased in the webpack config, but for some reason, which Jarrod and I are working on now, the dotenv alias within the
bundler-webpack
package itself is not working
so if you alias it yourself, in the meantime, it will work
@jarrod_not_jared can you point to the ecommerce example?
fyi the reason I need to reference dotenv myself is
https://github.com/payloadcms/payload/issues/3330This is the current workaround:
https://github.com/payloadcms/payload/blob/main/templates/ecommerce/src/payload/payload.config.ts#L62hey @tyteen4a03 we updated the webpack bundler so if u update, you should be good now
Yep, works now!
Star
Discord
online
Get dedicated engineering support directly from the Payload team..