asyncapi / generator

Use your AsyncAPI definition to generate literally anything. Markdown documentation, Node.js code, HTML documentation, anything!
https://asyncapi.com/docs/tools/generator
Apache License 2.0
755 stars 211 forks source link

Generator stopped working with new npm version #434

Closed Vanderhoof closed 3 years ago

Vanderhoof commented 3 years ago

Describe the bug

I have updated npm to 7.0.5 version and generator command started crashing with error:

Something went wrong:
TypeError: must call as: npm.load(callback)
    at Object.load (/usr/local/lib/node_modules/npm/lib/npm.js:127:13)
    at npmi (/usr/local/lib/node_modules/@asyncapi/generator/node_modules/npmi/npmi.js:189:9)
    at /usr/local/lib/node_modules/@asyncapi/generator/lib/generator.js:356:7

The error is raised here in npm module

I am launching the command like this:

ag  generated/asyncapi.json templates/ag-html-with-bindings/ -o ./generated/async

I can't find the solution in the web, and honestly I am not an experienced node user so I have almost no idea of how to treat this error. It may be possible that I am doing something wrong, any help appreciated

Thank you!

UPD: I am running macOS Catalina 10.15.6, but first this error appeared in my docker container which is derived from node:latest. In fact, I started experiencing this error after recently pulling the fresh node:latest image

derberg commented 3 years ago

@Vanderhoof hey, thanks for reporting it. I don't think we can call this one a bug. We openly state what version of node and npm are supported -> https://github.com/asyncapi/generator#requirements. We even explicitly make sure what version of npm to install https://github.com/asyncapi/generator/blob/master/Dockerfile#L10-L11. Also have a look at https://github.com/asyncapi/generator/blob/master/package.json#L10-L13

Official LTS support for node 14 will start pretty soon (https://nodejs.org/en/about/releases/) and I guess we will work on upgrading to node 14 and npm 7 at the same time

Vanderhoof commented 3 years ago

@derberg Thank you for reply!

It finally got me unstuck and I solved the issue by changing node:latest to node:14. Might as well try using the Docker image of asyncapi-generator inside my container instead of installing it natively.

But now our pipeline is finally working, after two days, so thank you again : }