tweaselORG / appstraction

An abstraction layer for common instrumentation functions (e.g. installing and starting apps, setting preferences, etc.) on Android and iOS.
MIT License
6 stars 1 forks source link

Appstraction download via npm fails on Ubuntu #109

Closed synapticlee closed 1 year ago

synapticlee commented 1 year ago

Hi, raising a separate issue that I also ran into problems installing appstraction using npm on ubuntu:

npm ERR! code 1
npm ERR! path /home/parallels/exodus-standalone/node_modules/appstraction
npm ERR! command failed
npm ERR! command sh -c node scripts/postinstall.js; andromatic-install -p platform-tools 'build-tools;33.0.2'
npm ERR! file:///home/parallels/exodus-standalone/node_modules/autopy/dist/index.js:31
npm ERR!     const version = versionRange ?? ">= 0";
npm ERR!                                   ^
npm ERR! 
npm ERR! SyntaxError: Unexpected token '?'
npm ERR!     at Loader.moduleStrategy (internal/modules/esm/translators.js:133:18)
npm ERR! file:///home/parallels/exodus-standalone/node_modules/andromatic/dist/cli-install.js:33
npm ERR!     ].filter((v)=>options?.allowPrerelease === undefined || options?.allowPrerelease || !v.includes("-rc")).sort((a, b)=>{
npm ERR!                           ^
npm ERR! 
npm ERR! SyntaxError: Unexpected token '.'
npm ERR!     at Loader.moduleStrategy (internal/modules/esm/translators.js:133:18)
npm ERR!     at async link (internal/modules/esm/module_job.js:42:21)

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/parallels/.npm/_logs/2023-06-30T13_57_29_648Z-debug-0.log
zner0L commented 1 year ago

What version of nodejs are you running, i.e. what is the output of node -v? We require at least v18 .

zner0L commented 1 year ago

I can reproduce the problem by installing nodejs and npm on a brand new Ubuntu 22.04 LTS:

$ sudo apt install nodejs npm
$ mkdir appstraction-test && cd appstraction-test
$ npm install appstraction
npm ERR! code 1
npm ERR! path /home/raven/appstraction-test/node_modules/appstraction
npm ERR! command failed
npm ERR! command sh -c node scripts/postinstall.js; andromatic-install -p platform-tools 'build-tools;33.0.2'
npm ERR! file:///home/raven/appstraction-test/node_modules/autopy/dist/index.js:31
npm ERR!     const version = versionRange ?? ">= 0";
npm ERR!                                   ^
npm ERR! 
npm ERR! SyntaxError: Unexpected token '?'
npm ERR!     at Loader.moduleStrategy (internal/modules/esm/translators.js:133:18)
npm ERR! file:///home/raven/appstraction-test/node_modules/andromatic/dist/cli-install.js:33
npm ERR!     ].filter((v)=>options?.allowPrerelease === undefined || options?.allowPrerelease || !v.includes("-rc")).sort((a, b)=>{
npm ERR!                           ^
npm ERR! 
npm ERR! SyntaxError: Unexpected token '.'
npm ERR!     at Loader.moduleStrategy (internal/modules/esm/translators.js:133:18)
npm ERR!     at async link (internal/modules/esm/module_job.js:42:21)

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/raven/.npm/_logs/2023-07-06T14_13_04_986Z-debug-0.log

This is not surprising, because the error says it doesn’t recognize the nullish coalescing operator (??), which was introduced in version 14.0.0. Unfortunately, Ubuntu lags behind quite a lot in terms of node versions. We require >= 18.0.0 , though it seems we don’t mention that anywhere. I am sorry.


I’d recommend to install version 18 via nvm like this:

# Install nvm, see https://github.com/nvm-sh/nvm#install--update-script for the most recent manual
$ wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
# Restart your terminal
$ nvm install v18
# Verify your version
$ node --version
v18.16.1

I verified the installation works if you do so.