Hello, maybe someone could help, I am developing a project based on this boilerplate:
https://github.com/payloadcms/nextjs-custom-serverI I build and serve the project I get
MODULE_NOT_FOUND
error when trying to import my custom view in a payload collection.
Here is the output:
yarn run v1.22.19
$ cross-env NODE_ENV=production PAYLOAD_CONFIG_PATH=dist/payload.config.js node dist/server.js
[10:01:54] INFO (payload): Connected to Mongo server successfully!
[10:01:54] INFO (payload): Starting Payload...
unhandledRejection Error: Cannot find module '../components/CustomMinimalView'
Require stack:
- /dist/collections/Page.js
- /dist/payload.config.js
- /node_modules/payload/dist/config/load.js
- /node_modules/payload/dist/payload.js
- /node_modules/payload/dist/initHTTP.js
- /node_modules/payload/dist/index.js
- /dist/server.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:985:15)
at Function.mod._resolveFilename (/node_modules/next/dist/build/webpack/require-hook.js:23:32)
at Function.Module._load (node:internal/modules/cjs/loader:833:27)
at Module.require (node:internal/modules/cjs/loader:1057:19)
at require (node:internal/modules/cjs/helpers:103:18)
at Object.<anonymous> (/dist/collections/Page.js:11:43)
at Module._compile (node:internal/modules/cjs/loader:1155:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1209:10)
at Module.load (node:internal/modules/cjs/loader:1033:32)
at Function.Module._load (node:internal/modules/cjs/loader:868:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/dist/collections/Page.js',
'/dist/payload.config.js',
'/node_modules/payload/dist/config/load.js',
'/node_modules/payload/dist/payload.js',
'/node_modules/payload/dist/initHTTP.js',
'/node_modules/payload/dist/index.js',
'/dist/server.js'
]
}
That would mean the path to the imported module is not correct I believe
Can you confirm that
'../components/CustomMinimalView'
is correct
That's correct, I forgot to write that running the dev script it works, this problem only came up on compiled files. I also verified that the file is included in the build and it is
ahhhh I was talking to someone in another thread with the same issue. I will try to find and tag it here, it was also un resolved, but will be nice to tie them together.
NextJS Custom Server - Error resolving module
Yes, we solved this in Github, here it is:
https://github.com/payloadcms/nextjs-custom-server/issues/30The tsconfig file was missing the jsx option
Oh awesome! 😅😅
Star
Discord
online
Get help straight from the Payload team with an Enterprise License.