[BUG] Installing the CLI through Chocolatey produces bugs in `generate` commands
- Dominant language
- TypeScript
- Stars
- 272
- Forks
- 375
- Avg merge
- 3h 22m
- Merged PRs (30d)
- 8
Description
### 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:
4. Clone @asyncapi/nodejs-template
5. Run `npm i`
6. 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?
- [x] I checked and didn't find similar issue
### 🏢 Have you read the Contributing Guidelines?
- [x] I have read the [Contributing Guidelines](https://github.com/asyncapi/.github/blob/master/CONTRIBUTING.md)
### Are you willing to work on this issue ?
No, someone else can work on it
Contributor guide
Research direction
Start at the CLI's `generate fromTemplate` entry point and compare module resolution in the Chocolatey and NPM installations, using the reported Windows reproduction commands. Inspect the stack-trace locations in `@asyncapi/generator/lib/utils.js` and `lib/generator.js`; done means the remote and local template examples work from the Chocolatey installation without manual template installation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- nodejs, typescript
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100