Djkáťo
Djkáťo5w 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?
2 Replies
Djkáťo
DjkáťoOP2w ago
I had to enable "nodeModulesDir": true,, now it runs this no longer works as a workaround
$: deno task --filter "backend" dev
deno task --filter "backend" dev
Warning `"nodeModulesDir": true` is deprecated in Deno 2.0. Use `"nodeModulesDir": "auto"` instead
at file:.../monorepo/deno.json
Warning The following packages are deprecated:
┠─ npm:@esbuild-kit/esm-loader@2.6.5 (Merged into tsx: https://tsx.is)
┠─ npm:@esbuild-kit/core-utils@3.3.2 (Merged into tsx: https://tsx.is)
┖─ npm:node-domexception@1.0.0 (Use your platform's native DOMException instead)
Task dev next dev
Warning `"nodeModulesDir": true` is deprecated in Deno 2.0. Use `"nodeModulesDir": "auto"` instead
at file:.../monorepo/deno.json
Warning The following packages are deprecated:
┠─ npm:@esbuild-kit/esm-loader@2.6.5 (Merged into tsx: https://tsx.is)
┠─ npm:@esbuild-kit/core-utils@3.3.2 (Merged into tsx: https://tsx.is)
┖─ npm:node-domexception@1.0.0 (Use your platform's native DOMException instead)
error: Uncaught (in promise) TypeError: Relative import path "@payloadcms/next/withPayload" not prefixed with / or ./ or ../ and not in import map from "file:.../monorepo/backend/next.config.mjs"
at file:.../monorepo/backend/next.config.mjs:1:29
at async loadConfig (file:.../monorepo/node_modules/.deno/next@15.2.3/node_modules/next/dist/server/config.js:964:36)
at async Module.nextDev (file:.../monorepo/node_modules/.deno/next@15.2.3/node_modules/next/dist/cli/next-dev.js:189:14)
$: deno task --filter "backend" dev
deno task --filter "backend" dev
Warning `"nodeModulesDir": true` is deprecated in Deno 2.0. Use `"nodeModulesDir": "auto"` instead
at file:.../monorepo/deno.json
Warning The following packages are deprecated:
┠─ npm:@esbuild-kit/esm-loader@2.6.5 (Merged into tsx: https://tsx.is)
┠─ npm:@esbuild-kit/core-utils@3.3.2 (Merged into tsx: https://tsx.is)
┖─ npm:node-domexception@1.0.0 (Use your platform's native DOMException instead)
Task dev next dev
Warning `"nodeModulesDir": true` is deprecated in Deno 2.0. Use `"nodeModulesDir": "auto"` instead
at file:.../monorepo/deno.json
Warning The following packages are deprecated:
┠─ npm:@esbuild-kit/esm-loader@2.6.5 (Merged into tsx: https://tsx.is)
┠─ npm:@esbuild-kit/core-utils@3.3.2 (Merged into tsx: https://tsx.is)
┖─ npm:node-domexception@1.0.0 (Use your platform's native DOMException instead)
error: Uncaught (in promise) TypeError: Relative import path "@payloadcms/next/withPayload" not prefixed with / or ./ or ../ and not in import map from "file:.../monorepo/backend/next.config.mjs"
at file:.../monorepo/backend/next.config.mjs:1:29
at async loadConfig (file:.../monorepo/node_modules/.deno/next@15.2.3/node_modules/next/dist/server/config.js:964:36)
at async Module.nextDev (file:.../monorepo/node_modules/.deno/next@15.2.3/node_modules/next/dist/cli/next-dev.js:189:14)
was looking forward to trying out deno.json instead of package.json, but the constant errors don't seem to be worth it. moving all dependencies to package.json makes it work
marvinh.
marvinh.2w ago
If you feel like this is something that should be fixed in Deno be sure to open an issue here https://github.com/denoland/deno/issues . That's where the folks working on Deno itself hang out. The discord #help space is more of a "users helping users" kind of thing

Did you find this page helpful?