Doesn't support Node 10
dschnare opened this issue · 3 comments
I've found this API by stumbling on it via the ReDoc repo. Seems like this is what I want to use in order to combine all OpenAPI YAML files into a single JSON/YAML file.
However, I've noticed a few things that are just broken (version 0.0.2):
- There is a
node_modules/.bin/openapi-cli
file that has the following example/test content:'use strict'; exports.validate = function() { console.log("This is my first npm"); };
- When I try to run
node ./node_modules/.bin/openapi -h
, or any other command, I get the following error message:/Users/{redacted}/site/public/developers/api-reference/node_modules/simple-websocket/server.js:45 _handleListening = () => { ^ √ api-reference % ./node_modules/.bin/openapi-cli -h (master)api-reference ./node_modules/.bin/openapi-cli: line 1: use strict: command not found ./node_modules/.bin/openapi-cli: line 3: syntax error near unexpected token `(' ./node_modules/.bin/openapi-cli: line 3: `exports.validate = function() {' ?2 api-reference % node ./node_modules/.bin/openapi-cli -h (master)api-reference √ api-reference % node ./node_modules/.bin/openapi -h (master)api-reference /Users/{redacted}/site/public/developers/api-reference/node_modules/simple-websocket/server.js:45 _handleListening = () => { ^ SyntaxError: Unexpected token = at Module._compile (internal/modules/cjs/loader.js:723:23) at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10) at Module.load (internal/modules/cjs/loader.js:653:32) at tryModuleLoad (internal/modules/cjs/loader.js:593:12) at Function.Module._load (internal/modules/cjs/loader.js:585:3) at Module.require (internal/modules/cjs/loader.js:692:17) at require (internal/modules/cjs/helpers.js:25:18) at Object.<anonymous> (/Users/{redacted}/site/public/developers/api-reference/node_modules/@redocly/openapi-cli/lib/cli/preview-server/server.js:6:22) at Module._compile (internal/modules/cjs/loader.js:778:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
I have discovered that I was installing openapi-cli
and not @redocly/openapi-cli
, however even after correcting my install and purging all files related to the openapi-cli
, I get the same exact error.
Node: v10.17.0
NPM: 6.14.5
The problem is related to the package simple-websocket
having used the public class fields syntax that is still in Stage 3 and only supported in Nodejs 12+:
_handleListening = () => {
this.emit('listening')
}
To support Nodejs less than 12, it should be:
_handleListening () {
this.emit('listening')
}
I would propose that either simple-websocket
be refactored to support Node versions prior to version 12, or add a en engineStrict
and engines
to it's package.json
to prevent usage with an unsupported version of Node. Alternatively, this package would use engineStrict
and engines
to prevent usage of this module with an unsupported version of Node.
Thanks for the suggestion. We'll add engineStrict
and engines
to the package.json to both this and @redocly/openapi-cli