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

[BUG] Command generate fromTemplate brakes with MODULE_NOT_FOUND #1391

Closed
2 tasks done
anespinoza83-mms opened this issue Apr 25, 2024 · 6 comments
Closed
2 tasks done
Labels
bug Something isn't working

Comments

@anespinoza83-mms
Copy link

Describe the bug.

The command generate fromTemplates fails with error MODULE_NOT_FOUND.
Here the details.

$asyncapi generate fromTemplate src/asyncapi/LocationInfoUpdateEvents.json @asyncapi/html-template -o dist/LocationInfoUpdateEvents --force-write --debug
asyncapi_adoption.action.invoked        COUNTER {
  user: '420544b6-cd3f-4258-a4f0-c866cbaa5e8e',
  action: 'generate:fromTemplate'
}       1
┌  AsyncAPI Generator
│
Template is not available locally and expected location is undefined. Known details are: undefined Error: Cannot find module '@asyncapi\html-template\package.json'
Require stack:
- C:\Users\abcdefg\AppData\Roaming\npm\node_modules\noop.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:1140:15)
    at Function.Module._resolveFilename.sharedData.moduleResolveFilenameHook.installedValue [as _resolveFilename] (C:\Program Files\@asyncapi\cli\client\node_modules\@cspotcode\source-map-support\source-map-support.js:811:30)
    at resolveFileName (C:\Program Files\@asyncapi\cli\client\node_modules\resolve-from\index.js:29:39)
    at resolveFrom (C:\Program Files\@asyncapi\cli\client\node_modules\resolve-from\index.js:43:9)
    at module.exports (C:\Program Files\@asyncapi\cli\client\node_modules\resolve-from\index.js:46:47)
    at utils.getTemplateDetails (C:\Program Files\@asyncapi\cli\client\node_modules\@asyncapi\generator\lib\utils.js:196:30)
    at Generator.installTemplate (C:\Program Files\@asyncapi\cli\client\node_modules\@asyncapi\generator\lib\generator.js:561:24)
    at Generator.installAndSetupTemplate (C:\Program Files\@asyncapi\cli\client\node_modules\@asyncapi\generator\lib\generator.js:283:73)
    at Generator.generate (C:\Program Files\@asyncapi\cli\client\node_modules\@asyncapi\generator\lib\generator.js:196:16)
    at async Generator.generateFromString (C:\Program Files\@asyncapi\cli\client\node_modules\@asyncapi\generator\lib\generator.js:444:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    'C:\\Users\\abcdefg\\AppData\\Roaming\\npm\\node_modules\\noop.js'
  ]
}
Template installation started because the template cannot be found on disk.
Using npm registry registry.npmjs.org and authorization type anonymous to handle template installation.
◇  Generation failed
Generator Error: Installation failed
asyncapi_adoption.action.finished       COUNTER {
  user: '420544b6-cd3f-4258-a4f0-c866cbaa5e8e',
  action: 'generate:fromTemplate',
  template: '@asyncapi/html-template',
  success: false,
  asyncapi_version: '3.0.0',
  asyncapi_servers: 1,
  asyncapi_channels: 2,
  asyncapi_messages: 7,
  asyncapi_operations_send: 2,
  asyncapi_operations_receive: 0,
  asyncapi_schemas: 42
}       1
$asyncapi --version
@asyncapi/cli/1.9.1 win32-x64 node-v18.20.2
$npm --version
10.5.0
$node --version
v20.12.2
  • This issue was first observed with docker image asyncapi/cli:1.8.4
  • Source file passed asyncapi validate.

Expected behavior

The program should produce HTML files without issues

Screenshots

image

How to Reproduce

  1. Install asyncapi/cli as instructed
  2. Open a terminal session in the work directory
  3. Execute asyncapi generate fromTemplate src/asyncapi/source.json @asyncapi/html-template -o dist/dest --force-write --debug

🥦 Browser

Microsoft Edge

👀 Have you checked for similar open issues?

  • I checked and didn't find similar issue

🏢 Have you read the Contributing Guidelines?

Are you willing to work on this issue ?

No, someone else can work on it

@anespinoza83-mms anespinoza83-mms added the bug Something isn't working label Apr 25, 2024
@github-project-automation github-project-automation bot moved this to Backlog in CLI - Kanban Apr 25, 2024
Copy link
Contributor

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.

@anespinoza83-mms
Copy link
Author

This issue turns out to be related to certificates in npm.

Steps below work as workaround:

  1. Set environment variable
    NODE_TLS_REJECT_UNAUTHORIZED=0
  2. Download HTML-template manually
    npm install -g @asyncapi/[email protected]

@Amzani
Copy link
Collaborator

Amzani commented Apr 29, 2024

@anespinoza83-mms how did you install the CLI ?

@anespinoza83-mms
Copy link
Author

anespinoza83-mms commented Apr 29, 2024

I used different distributions. I will list them in order.

Docker

docker pull asyncapi/cli

Note: This worked fine the first time I used it. The issue was observed around 4/22.

Windows

I followed the instructions from this guideline
First attempted the NPM method, I installed node and double checked npm was installed. Then I ran

npm install -g @asyncapi/cli

I think at this point I started observing errors, so I tried chocolatey installation.

choco install asyncapi

With chocolatey installation was smooth.

@Souvikns
Copy link
Member

I was unable to reproduce the bug, I installed CLI using nodejs npm on windows by running npm i @asyncapi/cli and it worked as it was supposed to, and was able generate successfully.

@anespinoza83-mms
Copy link
Author

Sorry for not coming back to this before to input more feedback. The issue seems was caused by an outage on one of the 3rd party service-dependecies I don't recall if it was node JS itself. Anyways, I think this ticket can be closed, if I experience this issue again I will re-open this ticket or create a new one referencing to this. Thanks!

@github-project-automation github-project-automation bot moved this from To Triage to Done in CLI - Kanban Aug 20, 2024
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
Archived in project
Development

No branches or pull requests

3 participants