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

Error: ENOENT: no such file or directory index.html.js #526

Closed
nilkanth987 opened this issue Feb 6, 2024 · 7 comments
Closed

Error: ENOENT: no such file or directory index.html.js #526

nilkanth987 opened this issue Feb 6, 2024 · 7 comments
Labels
bug Something isn't working

Comments

@nilkanth987
Copy link

Describe the bug

NodeJS server crashing when trying to generate Static HTML documentation site using @asyncapi/generator and @asyncapi/html-template. Below are the logs produced by generator in debug mode

Template sources taken from XXXX/node_modules/@asyncapi/html-template.
Version of used template is 2.1.7.
[BABEL] Note: The code generator has deoptimised the styling of XXXX/node_modules/@asyncapi/html-template/template/js/asyncapi-ui.min.js as it exceeds the max of 500KB.
File XXXX/public/docs/ui/index.html.js couldn't be found. Error: ENOENT: no such file or directory, stat 'XXXX/public/docs/ui/index.html.js'

How to Reproduce

Here are the configurations

node : 17.8.0
"@asyncapi/generator": "^1.17.4",
"@asyncapi/html-template": "^2.1.7",

Code to generate docs

const generateHtmlDoc = async () => {
  try {
    const generator = new Generator('@asyncapi/html-template',
      path.resolve('public/docs/ui'),
      { debug: true })
    generator.generateFromFile('docs/asyncapi_test.yml')
  } catch (e) {
    // Added logs to debug if crashed
    console.log("Error api documentation")
    console.log(e)
  }
}

asyncapi_test.yml is same as available on https://raw.githubusercontent.com/asyncapi/asyncapi/2.0.0/examples/2.0.0/streetlights.yml

Expected behavior

It should not crash the server, catch the exception and generate proper debug logs.

@nilkanth987 nilkanth987 added the bug Something isn't working label Feb 6, 2024
Copy link

github-actions bot commented Feb 6, 2024

Welcome to AsyncAPI. Thanks a lot for reporting your first issue. Please check out our contributors guide and the instructions about a basic recommended setup useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.

@nilkanth987
Copy link
Author

Not sure if its the same issue but the error is same as #456

@nilkanth987
Copy link
Author

Receiving this error when updated the package

Version of used template is 2.1.7.
[BABEL] Note: The code generator has deoptimised the styling of XXXX/node_modules/@asyncapi/generator/node_modules/@asyncapi/html-template/template/js/asyncapi-ui.min.js as it exceeds the max of 500KB.
File XXXX/public/docs/ui/index.html.js couldn't be found. Error: ENOENT: no such file or directory, stat 'XXXX/public/docs/ui/index.html.js'
Warning: Each child in a list should have a unique "key" prop.

Check the top-level render call using <ul>. See https://reactjs.org/link/warning-keys for more information.
    at li
    at Operation (XXXX/node_modules/@asyncapi/generator/node_modules/@asyncapi/react-component/lib/cjs/containers/Operations/Operation.js:48:20)
    at li
    at ul
    at section
    at Operations (XXXX/node_modules/@asyncapi/generator/node_modules/@asyncapi/react-component/lib/cjs/containers/Operations/Operations.js:13:45)
    at div
    at div
    at div
    at section
    at AsyncApiLayout (XXXX/node_modules/@asyncapi/generator/node_modules/@asyncapi/react-component/lib/cjs/containers/AsyncApi/Layout.js:40:23)
    at AsyncApiComponent (XXXX/node_modules/@asyncapi/generator/node_modules/@asyncapi/react-component/lib/cjs/containers/AsyncApi/Standalone.js:99:28)
    at AsyncApiComponent (XXXX/node_modules/@asyncapi/generator/node_modules/@asyncapi/react-component/lib/cjs/containers/AsyncApi/AsyncApi.js:87:28)

My current config

node : 17.8.0
"@asyncapi/generator": "^1.17.5",

@derberg
Copy link
Member

derberg commented Feb 22, 2024

yo, I don't think that the errors you report here are related to crashing server

I invested some time in investigation

This is not a crashing operation

[BABEL] Note: The code generator has deoptimised the styling of XXXX/node_modules/@asyncapi/html-template/template/js/asyncapi-ui.min.js as it exceeds the max of 500KB.

This is coming from debug log, we do not throw error here: https://github.com/asyncapi/generator/blob/master/lib/utils.js#L28-L32

File XXXX/public/docs/ui/index.html.js couldn't be found. Error: ENOENT: no such file or directory, stat 'XXXX/public/docs/ui/index.html.js'

I'm using latest @asyncapi/html-template and @asyncapi/cli and works fine
my command 👇🏼

asyncapi generate fromTemplate https://raw.githubusercontent.com/asyncapi/spec/master/examples/streetlights-kafka-asyncapi.yml @asyncapi/html-template --force-write --debug

in your script for sure you need to fix generator.generateFromFile to run it with await

also can you share why you're working on server implementation, any particular use case you have?

@nilkanth987
Copy link
Author

@derberg , First of all thanks for taking time to look into the issue.

I checked and it does not crash for the production for script node app.js but it restarts nodemon used in development mode with script nodemon app.js.

Here is the screenshot of it.
Screenshot 2024-02-23 at 11 09 47 AM

I am using server implementation so that when I change the documentation it gets updated during deployment as we are just exposing this document in development server. Do you recommend using cmd line?

@derberg
Copy link
Member

derberg commented Mar 26, 2024

did you think maybe about enabling what you need by client side generation -> https://www.asyncapi.com/blog/event-driven-api-documentation-made-simple-clientside-rendering

@nilkanth987
Copy link
Author

Yeah I think its not a big deal. The production script is working as expected. I am closing this issue then.

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

2 participants