cli icon indicating copy to clipboard operation
cli copied to clipboard

TS Error when run generation

Open Tenischev opened this issue 2 years ago • 21 comments
trafficstars

Describe the bug

TypeScript error when run generation from template/

How to Reproduce

  1. Install node (tested with 16 and 18)
  2. Install latest cli
  3. Checkout asyncapi/java-spring-template
  4. Run command asyncapi generate fromTemplate tests/mocks/mqtt.yml @asyncapi/java-spring-template -o spring-output-test
  5. Error:
error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'es2022', 'esnext', 'node12', 'nodenext'.

Additional details: OS - Windows 11

asyncapi --version
@asyncapi/cli/0.40.8 win32-x64 node-v16.20.0

Expected behavior

No error when run generation from template

Tenischev avatar May 22 '23 17:05 Tenischev

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.

github-actions[bot] avatar May 22 '23 17:05 github-actions[bot]

@Souvikns I think you have access to windows, can you help with this issue 🙏

derberg avatar May 23 '23 08:05 derberg

here step by step drill down of commands, maybe this will help image

Tenischev avatar May 23 '23 08:05 Tenischev

OK, I am getting the same error on Mac as well.

Souvikns avatar May 23 '23 09:05 Souvikns

The command is running on the codebase without any issue, but in production, it is not working, I checked and all other commands are working, might be something wrong with the generator.

Not a fix but you can run the command by passing --module flag run asyncapi generate fromTemplate --module=none <rest of the parameters>

Souvikns avatar May 23 '23 09:05 Souvikns

Not a fix but you can run the command by passing --module flag run asyncapi generate fromTemplate --module=none <rest of the parameters>

Nope image

Tenischev avatar May 23 '23 10:05 Tenischev

generator do not support --module, the error comes like from TS compiler I think

derberg avatar May 23 '23 10:05 derberg

@Tenischev can you install typescript globally and try to run the command, it worked for me.

Screenshot 2023-05-23 at 4 19 11 PM

generator do not support --module, the error comes like from TS compiler I think

Yeah, the generator is written in javascript, it is a typescript issue.

Souvikns avatar May 23 '23 10:05 Souvikns

does it mean that typescript has to be moved to dependencies? it shouldn't be needed in production right? typescript should be required only in build time

derberg avatar May 23 '23 13:05 derberg

does it mean that typescript has to be moved to dependencies? it shouldn't be needed in production right? typescript should be required only in build time

typescript is just a compiler right we should not need it in production, no idea why this is happening.

https://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html looking at this typescript could be used as a dependency

Souvikns avatar May 23 '23 15:05 Souvikns

interesting

@Tenischev can you confirm if after typescript installation the issue was fixed?

derberg avatar May 24 '23 09:05 derberg

@Tenischev can you confirm if after typescript installation the issue was fixed?

Not confirmed image

Tenischev avatar May 24 '23 09:05 Tenischev

Working for me for the latest release image

chinma-yyy avatar May 24 '23 17:05 chinma-yyy

@Tenischev can you give it another try with latest 🙏

derberg avatar Jun 27 '23 14:06 derberg

@derberg the problem still there image

Tenischev avatar Jun 27 '23 14:06 Tenischev

@Tenischev did you install the CLI using npm?

Souvikns avatar Jul 12 '23 08:07 Souvikns

@Souvikns I don't think it matters. I had the same issue 2 days ago and did not have time to open a PR, but my idea for the fix was pretty dummy, removal of package-lock.json and then npm i to refresh dependencies and the lock file and add it to the PR. Cause 2 days ago I was playing with AsyncAPI CLI and AsyncAPI Generator CLI both from sources, and they both had issue and reinstallation of fresh dependencies fixed the problem. I suspect some dependency of dependency released some bug, and refresh of dependencies then makes a use of a fix I think. I hope that makes sense.

derberg avatar Jul 13 '23 15:07 derberg

Oh ok, I will then open a PR updating the package-lock. I was thinking that maybe packaging it into different installers creates a problem.

Souvikns avatar Jul 14 '23 07:07 Souvikns

@Tenischev 0.51 that was just released should fix it 🤞🏼

derberg avatar Jul 20 '23 11:07 derberg

@derberg I have a small update here. For the version @asyncapi/cli/0.54.4 win32-x64 node-v18.17.1. CLI-Generator will work IF:

  1. CMD is located in system volume (drive C for most Windows systems)
  2. CMD is run with Administrator privileges.

image In other cases I receive the same error "error TS6046: ..."

Tenischev avatar Sep 01 '23 14:09 Tenischev

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:

github-actions[bot] avatar Dec 31 '23 00:12 github-actions[bot]

@Tenischev are you still experiencing this issue?

Amzani avatar Apr 30 '24 07:04 Amzani