event-catalog / eventcatalog

An open source documentation tool to bring discoverability to your event-driven architectures
https://eventcatalog.dev
MIT License
1.68k stars 139 forks source link

Issue building empty template project with pnpm package manager #575

Open mortezaalizadeh opened 2 months ago

mortezaalizadeh commented 2 months ago

Hi,

I created a event-catalog project using the command npx @eventcatalog/create-eventcatalog@latest my-catalog. The build process works perfectly with "npm run build", but I'm encountering an error when switching to pnpm running "pnpm build" command. Running "pnpm dev" results in the same error.

Does anyone know how to successfully build an event-catalog project with pnpm?

Thanks!

` ╭─morteza@pop-os ~/tmp/my-catalog ‹main*› ╰─➤ pnpm build 1 ↵

my-catalog@0.1.0 build /home/morteza/tmp/my-catalog eventcatalog build

Building EventCatalog...

@eventcatalog/core@2.0.12 build npm run scripts:hydrate-content && astro check --minimumSeverity error && astro build

@eventcatalog/core@2.0.12 scripts:hydrate-content node scripts/catalog-to-astro-content-directory.js

node:internal/modules/run_main:129 triggerUncaughtException( ^

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'glob' imported from /home/morteza/tmp/my-catalog/.eventcatalog-core/scripts/catalog-to-astro-content-directory.js Did you mean to import "glob/dist/commonjs/index.js"? at packageResolve (node:internal/modules/esm/resolve:854:9) at moduleResolve (node:internal/modules/esm/resolve:927:18) at defaultResolve (node:internal/modules/esm/resolve:1157:11) at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:383:12) at ModuleLoader.resolve (node:internal/modules/esm/loader:352:25) at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:227:38) at ModuleWrap. (node:internal/modules/esm/module_job:87:39) at link (node:internal/modules/esm/module_job:86:36) { code: 'ERR_MODULE_NOT_FOUND' }

Node.js v20.15.0 node:child_process:965 throw err; ^

Error: Command failed: PROJECT_DIR='/home/morteza/tmp/my-catalog' CATALOG_DIR='/home/morteza/tmp/my-catalog/.eventcatalog-core' npm run build at genericNodeError (node:internal/errors:984:15) at wrappedFn (node:internal/errors:538:14) at checkExecSyncError (node:child_process:890:11) at execSync (node:child_process:962:15) at _Command. (/home/morteza/tmp/my-catalog/nodemodules/.pnpm/@eventcatalog+core@2.0.12@types+react-dom@18.3.0_@types+react@18.3.3_ramda@0.30.1vite@5.3.3@types+node@20.14.10_/node_modules/@eventcatalog/core/bin/dist/eventcatalog.cjs:3133:42) at _Command.listener [as _actionHandler] (/home/morteza/tmp/my-catalog/nodemodules/.pnpm/@eventcatalog+core@2.0.12@types+react-dom@18.3.0_@types+react@18.3.3_ramda@0.30.1vite@5.3.3@types+node@20.14.10_/node_modules/@eventcatalog/core/bin/dist/eventcatalog.cjs:1443:21) at /home/morteza/tmp/my-catalog/nodemodules/.pnpm/@eventcatalog+core@2.0.12@types+react-dom@18.3.0_@types+react@18.3.3_ramda@0.30.1vite@5.3.3@types+node@20.14.10_/node_modules/@eventcatalog/core/bin/dist/eventcatalog.cjs:2233:24 at _Command._chainOrCall (/home/morteza/tmp/my-catalog/nodemodules/.pnpm/@eventcatalog+core@2.0.12@types+react-dom@18.3.0_@types+react@18.3.3_ramda@0.30.1vite@5.3.3@types+node@20.14.10_/node_modules/@eventcatalog/core/bin/dist/eventcatalog.cjs:2141:16) at _Command._parseCommand (/home/morteza/tmp/my-catalog/nodemodules/.pnpm/@eventcatalog+core@2.0.12@types+react-dom@18.3.0_@types+react@18.3.3_ramda@0.30.1vite@5.3.3@types+node@20.14.10_/node_modules/@eventcatalog/core/bin/dist/eventcatalog.cjs:2231:31) at /home/morteza/tmp/my-catalog/nodemodules/.pnpm/@eventcatalog+core@2.0.12@types+react-dom@18.3.0_@types+react@18.3.3_ramda@0.30.1vite@5.3.3@types+node@20.14.10_/node_modules/@eventcatalog/core/bin/dist/eventcatalog.cjs:2042:31 { status: 1, signal: null, output: [ null, null, null ], pid: 243836, stdout: null, stderr: null }

Node.js v20.15.0  ELIFECYCLE  Command failed with exit code 1. ╭─morteza@pop-os ~/tmp/my-catalog ‹main*› `

carlosallexandre commented 1 month ago

Hey @mortezaalizadeh, is everything ok?

Setting the node-linker to hoisted when installing the dependencies with pnpm works fine. See the full command:

pnpx @eventcatalog/create-eventcatalog@latest eventcatalog && \ 
  cd eventcatalog && \
  rm -rf node_modules/ pnpm-lock.yaml && \
  pnpm i --node-linker hoisted && \
  pnpm dev

[!NOTE] node-linker setted to hoisted will create a flat node_modules like npm or yarn. Check here