I just updated to Payload 2 and get an error when I'm trying to use the payload cli (ex:
npm run payload migrate:create --file @payloadcms/db-mongodb/versions-v1-v2
or
npm run payload generate:types
Compiler doesn't find index.js files anymore. Any ideas?
Here is the output i get:
PAYLOAD_CONFIG_PATH=./payload.config.ts payload migrate:create @payloadcms/db-mongodb/versions-v1-v2
node:internal/modules/cjs/loader:995
const err = new Error(message);
^
Error: Cannot find module '../fields/FieldRichText/index.js'
Require stack:
- /workspaces/payload-cms-template/packages/website/payload/blocks/BlockRichText.ts
- /workspaces/payload-cms-template/packages/website/payload/collections/CollectionNews.ts
- /workspaces/payload-cms-template/packages/website/payload.config.ts
- /workspaces/payload-cms-template/node_modules/payload/dist/config/load.js
- /workspaces/payload-cms-template/node_modules/payload/dist/bin/generateGraphQLSchema.js
- /workspaces/payload-cms-template/node_modules/payload/dist/bin/index.js
- /workspaces/payload-cms-template/node_modules/payload/bin.js
at Module._resolveFilename (node:internal/modules/cjs/loader:995:15)
at Module._load (node:internal/modules/cjs/loader:841:27)
at Module.require (node:internal/modules/cjs/loader:1061:19)
at require (node:internal/modules/cjs/helpers:103:18)
at Object.<anonymous> (/workspaces/payload-cms-template/packages/website/payload/blocks/BlockRichText.ts:12:61)
at Module._compile (node:internal/modules/cjs/loader:1159:14)
at Module._compile (/workspaces/payload-cms-template/node_modules/pirates/lib/index.js:117:24)
at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
at Object.newLoader [as .ts] (/workspaces/payload-cms-template/node_modules/pirates/lib/index.js:121:7)
at Module.load (node:internal/modules/cjs/loader:1037:32) {
code: 'MODULE_NOT_FOUND',
...
}
Node.js v18.12.1
PAYLOAD_CONFIG_PATH=./payload.config.ts payload migrate:create @payloadcms/db-mongodb/versions-v1-v2
This is missing
--file
does adding that back make a difference?
Oh this was a copy-paste mistake.. i also get the error if i try to generate the types (
npm run payload generate:types
). Does the payload CLI use the default tsconfig.json in the folder? We have to separate tsconfig files, one for next.js and one for payload
The default unless specified otherwise.
how can i specify another config?
tsc can accept a
--project
switch, change that in your npm script
Alight, thanks a lot for your help
I'll give it a try next week
The problem wasn't directly related to the payload upgrade. It was caused by a second version of
@swc/core
(
1.3.82
) being installed by another dependency.
Star
Discord
online
Get help straight from the Payload team with an Enterprise License.