payloadcms / payload

Payload is the open-source, fullstack Next.js framework, giving you instant backend superpowers. Get a full TypeScript backend and admin panel instantly. Use Payload as a headless CMS or for building powerful applications.
https://payloadcms.com
MIT License
23.59k stars 1.5k forks source link

SyntaxError from `Lexical` when running `payload` command #7829

Closed tajultonim closed 1 month ago

tajultonim commented 1 month ago

Link to reproduction

No response

Payload Version

3.0.0-beta.90

Node Version

v20.9.0

Next.js Version

15.0.0-canary.104

Describe the Bug

After passing lexicalEditor as editor property in payload config, it is throwing error The requested module 'lexical' does not provide an export named '$createLineBreakNode'. I tried removing the property and works as expected. So there is something wrong with that package or I am doing something wrong.

Reproduction Steps

  1. Pass lexicalEditor as edior
  2. Run $npm run payload

This is my config file:

//payload.config.ts

import { postgresAdapter } from "@payloadcms/db-postgres";
import { nodemailerAdapter } from "@payloadcms/email-nodemailer";
import nodemailer from "nodemailer";
import { lexicalEditor } from '@payloadcms/richtext-lexical'
import path from "path";
import { buildConfig } from "payload";
import { fileURLToPath } from "url";

import { Users } from "./collections/Users";
import { Media } from "./collections/Media";

const filename = fileURLToPath(import.meta.url);
const dirname = path.dirname(filename);

export default buildConfig({
  editor: lexicalEditor({}),
  admin: {
    user: Users.slug,
    importMap: {
      baseDir: path.resolve(dirname),
    },
  },
  collections: [Users, Media],
  secret: process.env.PAYLOAD_SECRET || "",
  typescript: {
    outputFile: path.resolve(dirname, "payload-types.ts"),
  },
  db: postgresAdapter({
    pool: {
      connectionString: process.env.DATABASE_URI || "",
    },
    migrationDir: "./migrations",
  }),
  plugins: [],
});

And when running $npx payload or $npm run payload this is the error I am getting.

P:\Repo\e-commerce\node_modules\.pnpm\@payloadcms+richtext-lexical@3.0.0-beta.80_zie4k473dvnd5d2awgudb3jndq\node_modules\@payloadcms\richtext-lexical\src\features\blockquote\markdownTransformer.ts:4
import { $createLineBreakNode } from 'lexical'
         ^

SyntaxError: The requested module 'lexical' does not provide an export named '$createLineBreakNode'
    at ModuleJob._instantiate (node:internal/modules/esm/module_job:131:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:213:5)
    at async ModuleLoader.import (node:internal/modules/esm/loader:316:24)
    at bin (p:/Repo/e-commerce/node_modules/.pnpm/payload@3.0.0-beta.90_graphql@16.8.1_typescript@5.5.4/node_modules/payload/dist/bin/index.js:40:27)
    at async start (file:///P:/Repo/e-commerce/node_modules/.pnpm/payload@3.0.0-beta.90_graphql@16.8.1_typescript@5.5.4/node_modules/payload/bin.js:30:7)

Node.js v20.9.0

Any solution?

Adapters and Plugins

richtext-lexical

tajultonim commented 1 month ago

Sorry. For some reason pnpm was downloading unmet peer dependencies for Lexical. I removed the node_modules folder then cleared pnpm cache and reinstalled dependencies. It's all seems good now.

github-actions[bot] commented 3 weeks ago

This issue has been automatically locked. Please open a new issue if this issue persists with any additional detail.