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 · 11 comments
Open

dev fails because of astro #1064

Jessewb786 opened this issue Dec 20, 2024 · 11 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

> event-catalog@0.1.0 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.

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

4 participants