Unexpected token { in re.js after updating the ionic node module

I have a module, that is malfunctioning. Uninstalling and reinstalling it ultimately results in the same error. And I can see, that uninstalling it doesn’t get rid of all the files.


The module in question is Ionic

The error I’m getting ever since I tried to update it is:

(function (exports, require, module, __filename, __dirname) { const { MAX_SAFE_COMPONENT_LENGTH } = require('./constants')

SyntaxError: Unexpected token {
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:373:25)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/usr/local/lib/node_modules/@ionic/cli/node_modules/semver/index.js:2:20)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)

it is shown whenever I run an ionic command, even ionic --help

(btw. this line, that is shown from rs.js is the first line of the file)

I’ve tried uninstalling it with npm uninstall -g @ionic/cli and npm uninstall -g ionic (I also once accidentally typed npm uninstall - ionic. and it did something…)

And reinstalling it with npm install -g @ionic/cli

Tried this several times.

I’ve also updated node to 15.6.0.

I’ve also cleaned my cache with npm cache clean --force every step of the way

I have to admit I’m generally a bit confused about node modules and where they live. Because for Ionic there are files (I’m using MacOs 11.2.3) in /usr/local/lib/node_modules/@ionic/ But also in [user folder]/node_modules/@ionic And there’s a .ionic in the user folder.

Perhaps there is something I don’t understand How do I go about issues such as this?

(this was copied from my SO post)


This has nothing to do with Ionic.

something is wrong with my node install.

it seems I have 4 node installs:

running npm start on a createreactapp installed with v15.6.0, I get:

so somehow it is using node 4.5.0.
What’s going on?