Djkáťo
Djkáťo3w ago

Uncaught (in promise) TypeError: Relative import path "@payloadcms/next/withPayload" not prefixed

Trying to deno-ify my payloadcms project, and I'm facing import issues related to deno.json.
{
"name": "@project/backend",
"exports": "./src",
"tasks": {
"build": "next build",
"dev": "next dev",
"devsafe": "rm -rf .next && next dev",
"generate:importmap": "payload generate:importmap",
"generate:types": "payload generate:types",
},
"imports": {
"@payloadcms/next": "npm:@payloadcms/next@3.31.0/",
"@payloadcms/payload-cloud": "npm:@payloadcms/payload-cloud@3.31.0",
"@payloadcms/richtext-lexical": "npm:@payloadcms/richtext-lexical@3.31.0",
"cross-env": "npm:cross-env@^7.0.3",
"graphql": "npm:graphql@^16.8.1",
"next": "npm:next@15.2.3",
"payload": "npm:payload@3.31.0",
//...
}
}
{
"name": "@project/backend",
"exports": "./src",
"tasks": {
"build": "next build",
"dev": "next dev",
"devsafe": "rm -rf .next && next dev",
"generate:importmap": "payload generate:importmap",
"generate:types": "payload generate:types",
},
"imports": {
"@payloadcms/next": "npm:@payloadcms/next@3.31.0/",
"@payloadcms/payload-cloud": "npm:@payloadcms/payload-cloud@3.31.0",
"@payloadcms/richtext-lexical": "npm:@payloadcms/richtext-lexical@3.31.0",
"cross-env": "npm:cross-env@^7.0.3",
"graphql": "npm:graphql@^16.8.1",
"next": "npm:next@15.2.3",
"payload": "npm:payload@3.31.0",
//...
}
}
And the default template project does: next.config.mjs
import { withPayload } from "@payloadcms/next/withPayload";

const nextConfig = {
// Your Next.js config here
};
export default withPayload(nextConfig, { devBundleServerPackages: false });
import { withPayload } from "@payloadcms/next/withPayload";

const nextConfig = {
// Your Next.js config here
};
export default withPayload(nextConfig, { devBundleServerPackages: false });
Error:
Task dev next dev
error: Uncaught (in promise) TypeError: Relative import path "@payloadcms/next/withPayload" not prefixed with / or ./ or ../
hint: If you want to use a JSR or npm package, try running `deno add npm:@payloadcms/next/withPayload`
at file:///home/djkato/data/Code/backend/next.config.mjs:1:29
at async loadConfig (file://...dist/server/config.js:964:36)
at async getStartServerInfo (file:///.../next/15.2.3/dist/server/lib/app-info-log.js:95:5)
at async ServerImpl.<anonymous> (file:///.../next/15.2.3/dist/server/lib/start-server.js:232:41)
Task dev next dev
error: Uncaught (in promise) TypeError: Relative import path "@payloadcms/next/withPayload" not prefixed with / or ./ or ../
hint: If you want to use a JSR or npm package, try running `deno add npm:@payloadcms/next/withPayload`
at file:///home/djkato/data/Code/backend/next.config.mjs:1:29
at async loadConfig (file://...dist/server/config.js:964:36)
at async getStartServerInfo (file:///.../next/15.2.3/dist/server/lib/app-info-log.js:95:5)
at async ServerImpl.<anonymous> (file:///.../next/15.2.3/dist/server/lib/start-server.js:232:41)
I assume this is something to do with import/importMaps but I tried different combinations and it's failing still. How do I fix this?
1 Reply
Djkáťo
DjkáťoOP3w ago
I had to enable "nodeModulesDir": true,, now it runs

Did you find this page helpful?