cli
cli copied to clipboard
fromTemplate.js: Cannot find module './yamlAST'
Describe the bug
When running from an npm script (not a global install), the error
fromTemplate.js: Cannot find module './yamlAST'
occurs
How to Reproduce
In a project
npm i @asyncapi/cli --save-dev
npm i @asyncapi/markdown-template --save-dev
In package.json add a script similar to
"build:markdown": "asyncapi generate fromTemplate --force-write ./some-asyncapi.yml @asyncapi/markdown-template"
Run the script
npm run build:markdown
MacBook-Pro-3:consumption Richard.Collette$ npm run build:markdown
> [email protected] build:markdown
> asyncapi generate fromTemplate --force-write ./consumption-asyncapi.yml @asyncapi/markdown-template
[MODULE_NOT_FOUND] require failed to load /Users/Richard.Collette/Documents/code/onboarding/consumption/node_modules/@asyncapi/cli/lib/commands/generate/fromTemplate.js: Cannot find module './yamlAST'
Require stack:
- /Users/Richard.Collette/Documents/code/onboarding/consumption/node_modules/yaml-ast-parser/dist/src/loader.js
- /Users/Richard.Collette/Documents/code/onboarding/consumption/node_modules/yaml-ast-parser/dist/src/index.js
- /Users/Richard.Collette/Documents/code/onboarding/consumption/node_modules/@fmvilas/pseudo-yaml-ast/src/index.js
- /Users/Richard.Collette/Documents/code/onboarding/consumption/node_modules/@asyncapi/parser/lib/utils.js
- /Users/Richard.Collette/Documents/code/onboarding/consumption/node_modules/@asyncapi/parser/lib/customValidators.js
- /Users/Richard.Collette/Documents/code/onboarding/consumption/node_modules/@asyncapi/parser/lib/parser.js
- /Users/Richard.Collette/Documents/code/onboarding/consumption/node_modules/@asyncapi/parser/lib/index.js
- /Users/Richard.Collette/Documents/code/onboarding/consumption/node_modules/@asyncapi/generator/lib/generator.js
- /Users/Richard.Collette/Documents/code/onboarding/consumption/node_modules/@asyncapi/cli/lib/commands/generate/fromTemplate.js
- /Users/Richard.Collette/Documents/code/onboarding/consumption/node_modules/@oclif/core/lib/module-loader.js
- /Users/Richard.Collette/Documents/code/onboarding/consumption/node_modules/@oclif/core/lib/config/plugin.js
- /Users/Richard.Collette/Documents/code/onboarding/consumption/node_modules/@oclif/core/lib/config/config.js
- /Users/Richard.Collette/Documents/code/onboarding/consumption/node_modules/@oclif/core/lib/config/index.js
- /Users/Richard.Collette/Documents/code/onboarding/consumption/node_modules/@oclif/core/lib/command.js
- /Users/Richard.Collette/Documents/code/onboarding/consumption/node_modules/@oclif/core/lib/index.js
- /Users/Richard.Collette/Documents/code/onboarding/consumption/node_modules/@asyncapi/cli/bin/run
Expected behavior
Should generate the document using the template.
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.
@rcollette I tried to reproduce but all is fine.
package.json:
{
"scripts": {
"build:markdown": "asyncapi generate fromTemplate --force-write ./async.yml @asyncapi/markdown-template"
},
"dependencies": {
"@asyncapi/cli": "^0.26.1",
"@asyncapi/markdown-template": "^1.2.1"
}
}
run result:
npm run build:markdown
> build:markdown
> asyncapi generate fromTemplate --force-write ./async.yml @asyncapi/markdown-template
Generation in progress. Keep calm and wait a bit... done
Check out your shiny new generated files at xxxxxxxx.
Can you please try adding --debug flag? my details after debugging:
Template sources taken from /{path to project where package.json is}/node_modules/@asyncapi/markdown-template.
Version of used template is 1.2.1.
File /.../node_modules/@asyncapi/markdown-template/hooks couldn't be found. Error: ENOENT: no such file or directory, stat '/../node_modules/@asyncapi/markdown-template/hooks' #valid as hooks are not there. I admit error could be nicer
File /.../asyncapi.js couldn't be found. Error: ENOENT: no such file or directory, stat '/Users/wookiee/Desktop/asyncapi.js' #error sucks, related to entrypoint, should be better
logs show good template is used and generation finish with success
This issue has been automatically marked as stale because it has not had recent activity :sleeping:
It will be closed in 120 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation.
There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model.
Let us figure out together how to push this issue forward. Connect with us through one of many communication channels we established here.
Thank you for your patience :heart:
closing as there were no more details provided