Ember CLI fails after install on Ubuntu 22.04

I’ve used ember on earlier versions of Ubuntu. It seems to install OK with sudo npm install -g ember-cli. But trying to run any ember command gives this error:


    return this.addons.find((addon) => addon.pkg?.name === name);

SyntaxError: Unexpected token '.'

    at wrapSafe (internal/modules/cjs/loader.js:915:16)

    at Module._compile (internal/modules/cjs/loader.js:963:27)

    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)

    at Module.load (internal/modules/cjs/loader.js:863:32)

    at Function.Module._load (internal/modules/cjs/loader.js:708:14)

    at Module.require (internal/modules/cjs/loader.js:887:19)

    at require (internal/modules/cjs/helpers.js:74:18)

    at Object.<anonymous> (/usr/local/lib/node_modules/ember-cli/lib/utilities/get-config.js:4:15)

    at Module._compile (internal/modules/cjs/loader.js:999:30)

    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)

Any Ideas on how to fix this?

I’d guess your default node is a much older unsupported version

Thanks, that was the problem!

I found this nice table about node and ember versions: https://github.com/ember-cli/ember-cli/blob/master/docs/node-support.md

Why didn’t npm automatically install the version of node I needed when I installed ember-cli?

So updating node from v12 to 16 got me past the error I posted, but gave me a new error. I saw that I need node v18 for ember 5.30, so I reverted the machine and installed node v18. Then I tried installing ember sudo npm install -g ember-cli, and the ember install itself failed, as npm was missing modules.

After several tries, I found that I had to install node before npm, and use aptitude. To help others, here is the script I ended up with:

#node install commands from nodesource
sudo apt-get update
sudo apt-get install -y ca-certificates curl gnupg
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
NODE_MAJOR=18 # See  https://github.com/ember-cli/ember-cli/blob/master/docs/node-support.md   for which version to install
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list
sudo apt-get update
sudo apt-get install nodejs -y
#install npm
sudo apt-get install aptitude
sudo aptitude install npm  #apt alone leaves a bunch of unresolved dependencies!
#install ember
sudo npm install -g ember-cli@5.3.0

Ember works now! (haha you can see from the other posts how long it took to figure this out: 3 hrs)

FWIW a tool like nvm, asdf or volta can help manage node versions and installs them in a more isolated way so you don’t need to run with sudo or have any special permissions

1 Like

Thanks I’ll try that.