generator
generator copied to clipboard
Error "Cannot find module" when run from npm script.
Describe the bug
When trying to run ag via an npm script, an error occurs with incorrect pathing to the template module, yet the output file is generated.
Note that the node_modules folder is missing in the path.
Something went wrong:
Error: Cannot find module '/ProjectDir/@asyncapi/markdown-template/package.json'
Require stack:
- /ProjectDir/node_modules/@asyncapi/generator/cli.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at /ProjectDir/node_modules/@asyncapi/generator/cli.js:116:26
How to Reproduce
In the scripts section of a package.json, add the following script
"watch:markdown":"ag --watch-template --force-write ./my-asyncapi.yml @asyncapi/markdown-template"
Execute the script with npm run watch:markdown
Expected behavior
It should not error, especially since the file was actually generated.
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.
I can confirm I was able to replicate it on node 16 This is something that requires some investigation, super weird.
@rcollette Hey, we will pretty soon deprecate Generator CLI. We already enabled generator in AsyncAPI CLI
please use CLI with AsyncAPI CLI and if there are any issues with the watcher, these should be fixed there. After CLI installation just run asyncapi generate fromTemplate --help to learn more.
Thanks 🙏🏼