Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev fails because of astro #1064

Open
Jessewb786 opened this issue Dec 20, 2024 · 22 comments
Open

dev fails because of astro #1064

Jessewb786 opened this issue Dec 20, 2024 · 22 comments
Labels
bug Something isn't working

Comments

@Jessewb786
Copy link

I tried this:

Tried to run "dev": "eventcatalog dev" on a clean event-catalog after an npm install.

The issue seems to be regarding @astrojs/mdx not being imported.

This happened:

/Users/john_doe/.nvm/versions/node/v20.16.0/bin/npm run dev

> [email protected] dev
> eventcatalog dev

Setting up EventCatalog....
EventCatalog is starting at http://localhost:3000/docs
[astro] 11:21:17 AM [vite] Error when evaluating SSR module /Users/john_doe/Project/event-catalog/.eventcatalog-core/astro.config.mjs: failed to import "@astrojs/mdx"
[astro] |- Error: Cannot find module '@astrojs/mdx' imported from '/Users/<user>/Project/event-catalog/.eventcatalog-core/astro.config.mjs'
[astro]     at nodeImport (file:///Users/<user>/Project/event-catalog/node_modules/vite/dist/node/chunks/dep-CB_7IfJ-.js:53047:19)
[astro]     at ssrImport (file:///Users/john_doe/Project/event-catalog/node_modules/vite/dist/node/chunks/dep-CB_7IfJ-.js:52914:22)
[astro]     at eval (/Users/john_doe/Project/event-catalog/.eventcatalog-core/astro.config.mjs:5:37)
[astro]     at async instantiateModule (file:///Users/john_doe/Project/event-catalog/node_modules/vite/dist/node/chunks/dep-CB_7IfJ-.js:52972:5)
[astro] 
[astro] [astro] Unable to load your Astro config
[astro] 
[astro] Cannot find module '@astrojs/mdx' imported from '/Users/john_doe/Project/event-catalog/.eventcatalog-core/astro.config.mjs'
[astro]   Location:
[astro]     /Users/john_doe/Project/event-catalog/node_modules/vite/dist/node/chunks/dep-CB_7IfJ-.js:53047:19
[astro]   Stack trace:
[astro]     at nodeImport (file:///Users/john_doe/Project/event-catalog/node_modules/vite/dist/node/chunks/dep-CB_7IfJ-.js:53047:19)
[astro]     at eval (/Users/john_doe/Project/event-catalog/.eventcatalog-core/astro.config.mjs:5:37)
[astro] npx astro dev  exited with code 1
[
  {
    command: Command {
      close: [Subject],
      error: [Subject],
      stdout: [Subject],
      stderr: [Subject],
      timer: [Subject],
      killed: false,
      exited: true,
      index: 0,
      name: 'astro',
      command: 'npx astro dev ',
      prefixColor: '',
      env: [Object],
      cwd: '/Users/john_doe/Project/event-catalog/.eventcatalog-core',
      killProcess: [Function (anonymous)],
      spawn: [Function (anonymous)],
      spawnOpts: [Object],
      process: undefined,
      pid: 79660,
      stdin: [Socket]
    },
    index: 0,
    exitCode: 1,
    killed: false,
    timings: {
      startDate: 2024-12-20T10:21:15.482Z,
      endDate: 2024-12-20T10:21:17.537Z,
      durationSeconds: 2.054959167
    }
  }
]

Process finished with exit code 0

I expected this:

I, of course, expected the service to start-up normally on port 3000.

Is there a workaround?

No response

Anything else?

No response

EventCatalog Version

"@eventcatalog/core": "2.18.5"

Node.js Version

v20.16.0

Platform(s)

MacOS

Community Notes

  • Please vote by adding a 👍 reaction to the issue to help us prioritize.
  • If you are interested to work on this issue, please leave a comment.
@Jessewb786 Jessewb786 added the bug Something isn't working label Dec 20, 2024
@boyney123
Copy link
Collaborator

Hey @Jessewb786

Thanks for sharing this.

We have seen a few issues with this recently (check on Discord for convo)

Can you try this https://www.eventcatalog.dev/docs/development/guides/upgrading#having-problems

(Delete node_modules, lock files, .eventcatalog-core) and try again?

@Jessewb786
Copy link
Author

Jessewb786 commented Dec 20, 2024

@boyney123 Unfortunately, after trying that, I still get the following:

Setting up EventCatalog....
EventCatalog is starting at http://localhost:3000/docs
[astro] 14:51:31 [types] Generated 1ms
[astro] 14:51:31 [WARN] [vite] Failed to resolve dependency: react-compiler-runtime, present in client 'optimizeDeps.include'
[astro] 14:51:31 [ERROR] [UnhandledRejection] Astro detected an unhandled rejection. Here's the stack trace:
[astro] TypeError: fsevents.watch is not a function
[astro]     at createFSEventsInstance (file:///Users/john_doe/Project/event-catalog/node_modules/vite/dist/node/chunks/dep-BZMjGe_U.js:28338:25)
[astro]     at setFSEventsListener (file:///Users/john_doe/Project/event-catalog/node_modules/vite/dist/node/chunks/dep-BZMjGe_U.js:28394:16)
[astro]     at FsEventsHandler._watchWithFsEvents (file:///Users/john_doe/Project/event-catalog/node_modules/vite/dist/node/chunks/dep-BZMjGe_U.js:28598:18)
[astro]     at FsEventsHandler.initWatch (file:///Users/john_doe/Project/event-catalog/node_modules/vite/dist/node/chunks/dep-BZMjGe_U.js:28674:23)
[astro]     at FsEventsHandler._addToFsEvents (file:///Users/john_doe/Project/event-catalog/node_modules/vite/dist/node/chunks/dep-BZMjGe_U.js:28763:12)
[astro]     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
[astro]   Hint:
[astro]     Make sure your promises all have an `await` or a `.catch()` handler.
[astro]   Error reference:
[astro]     https://docs.astro.build/en/reference/errors/unhandled-rejection/
[astro]   Stack trace:
[astro]     at /Users/john_doe/Project/event-catalog/.eventcatalog-core/Users/john_doe/Project/event-catalog/node_modules/vite/dist/node/chunks/dep-BZMjGe_U.js:28338:25
[astro]     [...] See full stack trace in the browser, or rerun with --verbose.
[astro] 

P.S: Everything works fine again if I rollback to 2.16.6. The problem starts specifically with 2.17.0 with the introduction of Astro 5.

@eps90
Copy link

eps90 commented Dec 31, 2024

I also encountered this problem and I noticed it fails when project's package.json has a property type set to module, as I have some additional scripts there. Having that property on, npm install does not install all packages, including @astrojs/mdx. Bringing back package.json to look the same as the generated one fixes the problem (but doesn't fix ability to use modules in node.js). Tested on the latest 2.18.5 version

@Jessewb786
Copy link
Author

@eps90 Indeed, and what I find myself having to do is make everything is lazily computed so that when astro starts with the eventcatalog.config.js, it doesn't compute everything.

And then I still have the issue that I have dynamically resolved generators in my eventcatalog.config.js which are not needed when I run dev, so then I have this frankly sad if check:

if (scriptDirectory.endsWith(".eventcatalog-core")) {
 return [];
} else {
...
}

This lets me run the generate from package.json and also lets me run dev.

I would love to know if there is some other way of integrating dynamically resolved generators.
And they're dynamically resolved because they rely on a series of folders that contain spec files that are the output of yamlinc which stitches together components that are reused across multiple spec files.

@boyney123
Copy link
Collaborator

I'm not sure how to replicate this and @carlosallexandre looked too.

Going to close for now, as the latest version of the catalog does not seem to give this error?

If you can find a way we can replicate please feel free to open the issue.

@eps90
Copy link

eps90 commented Jan 7, 2025

@boyney123 My comment above was about the newest version of EventCatalog and I provided an information how to replicate that.

@boyney123 boyney123 reopened this Jan 7, 2025
@boyney123
Copy link
Collaborator

boyney123 commented Jan 7, 2025

Ah, thanks @eps90

This might help to replicate @carlosallexandre #1064 (comment)?

@carlosallexandre
Copy link
Contributor

image
I tried here without any success.

@eps90 I tried this way:

  1. Run npx @eventcatalog/create-eventcatalog@latest mdx-test
  2. Delete node_modules and package-lock.json
  3. Set type: "module" on package.json
  4. Run npm install
  5. Run npm run dev

@eps90
Copy link

eps90 commented Jan 9, 2025

@carlosallexandre Sorry for no response, I send some detailed steps to reproduce on Monday, if that's ok. I'm AFK until then

@boyney123
Copy link
Collaborator

Thank you @eps90

@Jessewb786
Copy link
Author

This issue is no longer occurring for me on the latest versions.
I'll let @eps90 handle it from here if it's still an issue.

@rcdailey
Copy link

Mine isn't working on version 2.19.3, I don't even get error output, dev just exits after 1 second:

PS C:\src\eventcatalog\src\ui> npm run dev

> [email protected] dev
> eventcatalog dev

Setting up EventCatalog....
EventCatalog is starting at http://localhost:3000/docs
PS C:\src\eventcatalog\src\ui>

@boyney123
Copy link
Collaborator

Strange @rcdailey , are you still having issues?

@rcdailey
Copy link

@boyney123 Looks like for whatever reason, the ui directory is causing some problem. Note from my last message that I have the eventcatalog site under src/ui in my git repo. I renamed ui to eventcatalog (so now the path is src/eventcatalog) and now it works fine.

Not sure what the root cause of that was due to lack of logs.

@boyney123
Copy link
Collaborator

@boyney123 Looks like for whatever reason, the ui directory is causing some problem. Note from my last message that I have the eventcatalog site under src/ui in my git repo. I renamed ui to eventcatalog (so now the path is src/eventcatalog) and now it works fine.

Not sure what the root cause of that was due to lack of logs.

OK interesting, never tried it as a sub directory yet, will try that when I get round to it.

How do you all feel if we close this issue, or is there still issues (stoppers) people are facing?

@nicolamassarenti
Copy link

nicolamassarenti commented Jan 31, 2025

Hi @boyney123,

I'm facing the same issue. This is what I have as output

❯ npm run dev

> [email protected] dev
> eventcatalog dev

Setting up EventCatalog....
EventCatalog is starting at http://localhost:3000/docs
[astro] npx astro dev  exited with code 1
[
  {
    command: Command {
      close: [Subject],
      error: [Subject],
      stdout: [Subject],
      stderr: [Subject],
      timer: [Subject],
      killed: false,
      exited: true,
      index: 0,
      name: 'astro',
      command: 'npx astro dev ',
      prefixColor: '',
      env: [Object],
      cwd: '/home/nicola/Documents/dende/dev/event-catalog/.eventcatalog-core',
      killProcess: [Function (anonymous)],
      spawn: [Function (anonymous)],
      spawnOpts: [Object],
      process: undefined,
      pid: 574014,
      stdin: [Socket]
    },
    index: 0,
    exitCode: 1,
    killed: false,
    timings: {
      startDate: 2025-01-31T22:20:34.047Z,
      endDate: 2025-01-31T22:20:37.794Z,
      durationSeconds: 3.7466281649999997
    }
  }
]

I run all these steps

  • Deleted .eventcatalog
  • Deleted node-modules and package-lock.json
  • Run again npm install
  • Tried a fresh new installation

@boyney123
Copy link
Collaborator

@nicolamassarenti Very strange, what OS and node version are you using?

@nicolamassarenti
Copy link

@nicolamassarenti Very strange, what OS and node version are you using?

@boyney123

  • Node: v18.20.6
  • OS:
Distributor ID:	Ubuntu
Description:	Ubuntu 23.04
Release:	23.04
Codename:	lunar

@megakid
Copy link

megakid commented Feb 3, 2025

I just checked out the asyncapi sample (https://github.com/event-catalog/eventcatalog-asyncapi-example) and ran into this issue out the box

Running node 22.5.1 on Windows

@jaredrussell
Copy link

Just as an additional data point, I was seeing the same error when trying to run a freshly created empty project. I was using pnpm to initialise the repo (e.g. pnpm dlx @eventcatalog/create-eventcatalog@latest . --empty followed by pnpm dev).

Switching to npm resolved the issue.

@boyney123
Copy link
Collaborator

Thanks @jaredrussell , yeah I don't believe we support pnpm at the moment, need to fix/explore why still.

@boyney123
Copy link
Collaborator

I just checked out the asyncapi sample (https://github.com/event-catalog/eventcatalog-asyncapi-example) and ran into this issue out the box

Running node 22.5.1 on Windows

Can you try this when you get a second? https://github.com/event-catalog/generators/tree/main/examples/generator-asyncapi/basic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

8 participants