NPM is confusing my Mautic 5 installation process

Your software
My Mautic version is: 5.1.0
My PHP version is: 8.1
My Database type and version is: MariaDB

Your problem
My problem is: I’m trying to install Mautic 5 via composer using this guide, I do not follow all the commands because some are outdated but I basically have the same flow. Everything goes smoothly until I get to the part where I have to install Nodejs and NPM, I install both using the steps from the official website with the following commands:

# installs nvm (Node Version Manager)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash

# download and install Node.js (you may need to restart the terminal)
nvm install 18

# verifies the right Node.js version is in the environment
node -v # should print `v18.20.4`

# verifies the right npm version is in the environment
npm -v # should print `10.7.0`

That installs nicely nicely, I then proceed to install composer and finally mautic:

cd /var/www/html
sudo COMPOSER_ALLOW_SUPERUSER=1 composer create-project mautic/recommended-project:^5.0 mautic --no-interaction

And that’s where I get the following error at the end of the installation script process:

> npm ci --prefer-offline --no-audit
sh: 1: npm: not found
Script npm ci --prefer-offline --no-audit handling the npm-ci event returned with error code 127
Script @npm-ci was called via post-update-cmd

So I went ahead and installed NPM with ‘apt install npm’ command, hoping that fixes the problem. But no dice, apart from that error code above, I now get the following error as well, as if installing npm from the default repo downgrades my nodejs:

npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: 'postcss-normalize-display-values@6.0.2',
npm WARN EBADENGINE   required: { node: '^14 || ^16 || >=18.0' },
npm WARN EBADENGINE   current: { node: 'v12.22.9', npm: '8.5.1' }
npm WARN EBADENGINE }

These errors are showing in the log: Showed in the above process.
Like why does it say I have an unsupported engine when node -v and npm -v checks out and different than what that error report says?

Steps I have tried to fix the problem: Showed in the above process as well.

It might be that you now have two versions of node installed and the mautic installation takes the node which is of wrong version.

As a quick workaround I would try spinning an official docker container for mautic and then just copy the source that is produced by the installation.

That way you do not have to deal with npm on the server.

I would actually love a docker version, but afaik there’s no official docker support yet?

https://hub.docker.com/r/mautic/mautic here’s the docker images :slight_smile:

Thank you, I’m finally able to install a dockerized version, however, it seems that the image is one version behind? What exactly is the process of updating here, since this is a docker version I assume we should never pull updates from the webapp’s UI?

You specify mautic version in env. variable here:

depending how you set other env. variables you may need to login to web container and execute migrations after the update.

I use this compose template basically and the env variables have a different format. Do I just append those env variables you sent or is there something I need to configure in the compose file?

I have not had time to fully test this myself, looking just add the Dockerfile MAUTIC_VERSION is build argument, so change that argument to whatever version works for you, build an image and use it in compose.

I think format of version is the same as tags in git, so if you do MAUTIC_VERSION=5.1.0 it will use source of mautic 5.