Skip to content

[BUG] Installing the CLI through Chocolatey produces bugs in generate commands #1743

Open

Description

@nightknighto

Describe the bug.

I installed the CLI through Window's Chocolatey as documented in the docs. However when attempting to use the generate command, it always failed to generate anything unless the template was pre-installed.

For example:

  • asyncapi generate fromTemplate asyncapi.yaml @asyncapi/nodejs-template fails. For it to work, I have to manually pre-install nodejs-template globally through NPM.
  • asyncapi generate fromTemplate asyncapi.yaml @asyncapi/html-template --use-new-generator -o docs2 fails. I have to manually pre-install the template too, either locally or globally.
  • asyncapi generate fromTemplate test/mocks/mqtt/asyncapi-v3.yml ./ -o test/output -p server=production fails. I can't use a local template.

This behavior is not present when installing the CLI through NPM. I uninstalled from Chocolatey and installed through NPM and everything worked fine.

Expected behavior

All the mentioned examples should work fine just like if I installed the CLI through NPM.

Screenshots

Output example from trying to use a local template:

PS H:\CODING\gsoc-2025\AsyncAPI-nodejs-template> asyncapi generate fromTemplate test/mocks/mqtt/asyncapi-v3.yml ./ -o test/output -p server=production --debug
asyncapi_adoption.action.invoked        COUNTER {
  user: 'bd3c5ac4-4047-4e72-b2ea-e76044adf92b',  
  action: 'generate:fromTemplate'
}       1
┌  AsyncAPI Generator
│
◐  Generation in progress. Keep calm and wait a bitTemplate is not available locally and expected location is undefined. Known details are: undefined Error: Cannot find module 'package.json'
Require stack:
- C:\Users\ahmed\AppData\Roaming\npm\node_modules\noop.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:1225:15)
    at Function.Module._resolveFilename.sharedData.moduleResolveFilenameHook.installedValue [as _resolveFilename] (C:\Program Files\@asyncapicli\client\node_modules\@cspotcode\s@cspotcode\source-map-support\source-map-support.js:811:30)
    at resolveFileName (C:\Program Files\@asyncapicli\client\node_modules\resolve-from\index.js:29:39)
    at resolveFrom (C:\Program Files\@asyncapicli\client\node_modules\resolve-from\index.js:43:9)
    at module.exports (C:\Program Files\@asyncapicli\client\node_modules\resolve-from\index.js:46:47)
    at utils.getTemplateDetails (C:\Program Files\@asyncapicli\client\node_modules\@asyncapi\generator\lib\utils.js:196:30)
    at Generator.installTemplate (C:\Program Files\@asyncapicli\client\node_modules\@asyncapi\generator\lib\generator.js:561:24)
    at Generator.installAndSetupTemplate (C:\Program Files\@asyncapicli\client\node_modules\@asyncapi\generator\lib\generator.js:283:73)
    at Generator.generate (C:\Program Files\@asyncapicli\client\node_modules\@asyncapi\generator\lib\generator.js:196:16)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Generator.generateFromString (C:\Program Files\@asyncapicli\client\node_modules\@asyncapi\generator\lib\generator.js:444:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ 'C:\\Users\\ahmed\\AppData\\Roaming\\npm\\node_modules\\noop.js' ]
}
Template installation started because the template cannot be found on disk.
Using npm registry https://registry.npmjs.org/ and authorization type anonymous to handle template installation.
◇  Generation failed
Generator Error: Installation failed
asyncapi_adoption.action.finished       COUNTER {
  user: 'bd3c5ac4-4047-4e72-b2ea-e76044adf92b',  
  action: 'generate:fromTemplate',
  template: './',
  success: false,
  asyncapi_version: '3.0.0',
  asyncapi_servers: 1,
  asyncapi_channels: 4,
  asyncapi_messages: 3,
  asyncapi_operations_send: 3,
  asyncapi_operations_receive: 1,
  asyncapi_schemas: 29,
  file_creation_timestamp: 1742515674002.0461    
}       1

How to Reproduce

  1. Install CLI through Chocolatey
  2. Create an example asyncapi.yaml file
  3. Run asyncapi generate fromTemplate asyncapi.yaml @asyncapi/html-template --use-new-generator -o docs2. It fails.

Additionally, try out a local template by:

  1. Clone @asyncapi/nodejs-template
  2. Run npm i
  3. Run asyncapi generate fromTemplate test/mocks/mqtt/asyncapi-v3.yml ./ -o test/output -p server=production. It fails as well

🖥️ Device Information [optional]

  • Operating System (OS): Windows 10

👀 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

Activity

  1. added
    bug
    on Mar 21, 2025
  2. github-actions commented on Mar 21, 2025

    @github-actions
    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.

  3. Souvikns commented on Jun 12, 2025

    @Souvikns
    Member

    Currently trying to install ayncapi from chocolatey and getting error.

    asyncapi not installed. An error occurred during installation:
     Unable to obtain lock file access on 'C:\ProgramData\chocolatey\lib\2444580fb1ea03938f6c63a43aa78ce229cd72d4' for operations on 'C:\ProgramData\chocolatey\lib\asyncapi'. This may mean that a different user or administrator is holding this lock and that this process does not have permission to access it. If no other process is currently performing an operation on this file it may mean that an earlier NuGet process crashed and left an inaccessible lock file, in this case removing the file 'C:\ProgramData\chocolatey\lib\2444580fb1ea03938f6c63a43aa78ce229cd72d4' will allow NuGet to continue.
    
  4. Souvikns commented on Jun 12, 2025

    @Souvikns
    Member

    The command is also failing in development environment, might be happening due to some library in generator. Giving it a look. Not really a chocolatey issue though I haven't tried it using npm, I mean the dev env is not working so safe to say won't work in npm install either.

    Failing in linux as well

    souvik  asyncapicli  asyncapi generate fromTemplate asyncapi.yaml @asyncapi/nodejs-template
    asyncapi_adoption.action.invoked	COUNTER	{
      user: '78570d48-52c1-497d-b6ca-cbaaff952459',
      action: 'generate:fromTemplate'
    }	1
    ┌  AsyncAPI Generator
    │
    ◇  Please provide the output directory
    │  ./code
    │
    ◇  Generation failed
    Generator Error: Installation failed
    asyncapi_adoption.action.finished	COUNTER	{
      user: '78570d48-52c1-497d-b6ca-cbaaff952459',
      action: 'generate:fromTemplate',
      template: '@asyncapi/nodejs-template',
      success: false,
      asyncapi_version: '2.2.0',
      asyncapi_servers: 0,
      asyncapi_channels: 1,
      asyncapi_messages: 1,
      asyncapi_operations_send: 1,
      asyncapi_operations_receive: 0,
      asyncapi_schemas: 3,
      file_creation_timestamp: 1749736806210.2266
    }	1
     ✘ souvik  asyncapicli       
    
    

    Definitely not a windows issue, looks like it is a generator issue. In general generator is unable to install the templates properly.

  5. aialok commented on Oct 7, 2025

    @aialok

    @AayushSaini101 Can you please assign me this issue?

  6. DarshanCode2005 commented on Nov 28, 2025

    @DarshanCode2005
    Contributor

    @Souvikns is this issue still open, I would like to give this a try! Please assign this to me, thanks.

  7. Shurtu-gal commented on Dec 17, 2025

    @Shurtu-gal
    Collaborator

    @DarshanCode2005 please go ahead and create a PR

  8. utkarshgupta2804 commented on Dec 25, 2025

    @utkarshgupta2804
    Image

    I was looking into this issue @Shurtu-gal ,
    I tried these command:

    1. Clone @asyncapi/nodejs-template
    2. Run npm i
    3. Run asyncapi generate fromTemplate test/mocks/mqtt/asyncapi-v3.yml ./ -o test/output -p server=production. It fails as well

    steps well for me it actually works
    Let me check initial command and update you.

  9. DarshanCode2005 commented on Dec 25, 2025

    @DarshanCode2005
    Contributor

    Hi @Shurtu-gal, I’m working on this issue. I was previously assigned another issue in the conference-website to build the complete registration workflow for 2026, which I’ve completed. I’ll update you on this one soon 😊

  10. Varadraj75 commented on Jan 3, 2026

    @Varadraj75
    Contributor

    Hi @Shurtu-gal ,

    ### My understanding:
    The asyncapi validate command currently doesn’t fail when the AsyncAPI document references external files that can’t be resolved. Instead of showing an error for missing or unreachable references, the CLI just exits successfully, which can hide broken definitions.

    ### My approach:
    I would like to reproduce the problem with missing references, identify where the resolution is silently ignored, and improve the validator so it reports unresolved references as errors.

    If this approach sounds good to you, may I go ahead and raise a PR for it?

  11. shivansh-source commented on Feb 12, 2026

    @shivansh-source

    Testing Update: Original Bug Appears Fixed ✅

    Following up on @Souvikns 's finding that this was a generator issue (not CLI-specific), I've tested the current generator version and the bug appears to be resolved.

    Test Environment

    • Generator: v3.1.2
    • Node: v24.13.1
    • CLI: Latest (via npm)
    • OS: Linux

    Test Results

    ✅ Templates now install automatically without requiring manual pre-installation

    Command tested:

    asyncapi generate fromTemplate asyncapi.yaml @asyncapi/html-template -o ./docs
  12. shivansh-source commented on Feb 12, 2026

    @shivansh-source

    Result: Files generated successfully with no "Cannot find module 'package.json'" error.
    Created asyncapi/generator#1983 to track this in the generator repo, where the fix was needed.
    The original bug appears to be fixed in current versions. Additional testing on Windows with Chocolatey installation would be helpful to fully confirm, but the core generator issue is resolved.

    Can this issue be closed, or should we wait for Windows/Chocolatey-specific testing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions