getgauge / gauge

Light weight cross-platform test automation
https://gauge.org
Apache License 2.0
2.99k stars 344 forks source link

"SyntaxError: Unexpected token function" when installing Gauge via npm #1315

Closed glalejos closed 5 years ago

glalejos commented 5 years ago

Hi, I'm trying to install Gauge with the command npm --registry http://localhost:39720/repository/npm-group/ install -g @getgauge/cli, but I get the following error:

/opt/node-v6.12.3-linux-x64/bin/gauge -> /opt/node-v6.12.3-linux-x64/lib/node_modules/@getgauge/cli/bin/gauge

> @getgauge/cli@1.0.3 install /opt/node-v6.12.3-linux-x64/lib/node_modules/@getgauge/cli
> node ./src/index.js

/opt/node-v6.12.3-linux-x64/lib/node_modules/@getgauge/cli/src/index.js:14
var downloadAndExtract = async function(version) {
                               ^^^^^^^^

SyntaxError: Unexpected token function
    at createScript (vm.js:56:10)
    at Object.runInThisContext (vm.js:97:10)
    at Module._compile (module.js:542:28)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.runMain (module.js:604:10)
    at run (bootstrap_node.js:383:7)
    at startup (bootstrap_node.js:149:9)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @getgauge/cli@1.0.3 install: `node ./src/index.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @getgauge/cli@1.0.3 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2019-01-22T22_02_58_956Z-debug.log

I'm using npm 6.6.0, and I can install other packages via npm without problem.

Any idea on what might be wrong?

Thank you,

Guillermo

sriv commented 5 years ago

I guess you need node 8+, since the script uses some ES6 (in this case async) syntax.

If you plan to use gauge-js plugin, then it only works with node 8+.

glalejos commented 5 years ago

Thanks @sriv, that moved forward the installation process!.

However it is unable to successfully complete the installation:

root@debian:~# npm install -g @getgauge/cli
/opt/node-v10.15.0-linux-x64/bin/gauge -> /opt/node-v10.15.0-linux-x64/lib/node_modules/@getgauge/cli/bin/gauge

> @getgauge/cli@1.0.3 install /opt/node-v10.15.0-linux-x64/lib/node_modules/@getgauge/cli
> node ./src/index.js

Fetching download url for Gauge version 1.0.3
TypeError: Cannot read property 'assets' of undefined
    at Request.request.get [as _callback] (/opt/node-v10.15.0-linux-x64/lib/node_modules/@getgauge/cli/src/install.js:46:40)
    at self.callback (/opt/node-v10.15.0-linux-x64/lib/node_modules/@getgauge/cli/node_modules/request/request.js:185:22)
    at Request.emit (events.js:182:13)
    at Request.onRequestError (/opt/node-v10.15.0-linux-x64/lib/node_modules/@getgauge/cli/node_modules/request/request.js:881:8)
    at ClientRequest.emit (events.js:182:13)
    at TLSSocket.socketErrorListener (_http_client.js:392:9)
    at TLSSocket.emit (events.js:182:13)
    at emitErrorNT (internal/streams/destroy.js:82:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
    at process._tickCallback (internal/process/next_tick.js:63:19)
+ @getgauge/cli@1.0.3
updated 1 package in 143.555s

I bet this is related to the proxy.

How can I define the proxy in order to complete the installation?

Thank you,

Guillermo

sriv commented 5 years ago

hi @glalejos - can you please try setting the proxy as an environment variable?

glalejos commented 5 years ago

Thanks @sriv. I was missing the http_proxy environment variable - which I was pretty sure was defined, sorry for not double checking before asking - I got another error after that one, but it went away when I connected to a proxyless network at home... The important part is that Gauge is now installed. Thanks again.