Installing Magnolia through npm CLI

This page explains how you can use npm CLI to install the Community Edition of Magnolia.

Prerequisites

Get Java

Magnolia needs at least a Java Runtime Environment (JRE) to run. Check if there’s a version of Java already installed on your computer by opening the terminal or command prompt and typing java -version. If the system reports a version number, Java is installed on your computer.

See Certified stack to confirm that the version installed is supported.

For local development, use 17.0.12-zulu. Example installation using SDKMAN:

sdk install java 17.0.12-zulu
  • Windows

  • Mac

  • Linux

On Windows, you need a Java SE Development Kit (JDK). The Java Runtime Environment (JRE) is not enough because the Tomcat application server does not recognize it.

  • JRE is for users who run Java programs on their computers.

  • JDK is for developers who write Java-based applications.

Download and install JDK. By default, JDK is installed at C:\Program Files\Java\jdk-<version>\.

Instructions

Check for JAVA_HOME

  1. Open the command prompt.

  2. Type set and press ENTER.

  3. Find JAVA_HOME in the command output and verify that the path points to your JDK installation directory, for example, C:\Program Files\Java\jdk-<version>>.xx.

  4. If JAVA_HOME is missing or it points to the wrong directory, see Set JAVA_HOME.

Set JAVA_HOME

  1. Open the Command Prompt as an administrator.

  2. Set the path for JAVA_HOME.

    setx /m JAVA_HOME "path\to\Java\jdk" (1)
    1 Where path\to\Java\jdk is where your Java Development Kit is saved.

The set command creates the JAVA_HOME environment variable and sets its value to the JDK directory. The command is executed when Magnolia starts.

For Mac, you need to download or update to Java 17 or higher. After reviewing and agreeing to the terms of the license agreement, download the file, then double-click it to launch the installation wizard and follow the installation instructions.

The installation directory varies from one Linux system to another. On Debian-based distributions, JREs or JDKs are usually installed in /usr/lib/jvm/.

Get nodejs and npm

Magnolia CLI runs on Node.js and npm, the Node.js package manager. Use the following two shell commands to check that you have both of them installed:

node -v
npm -v

If you do not have Node.js installed, go to Node.js, download and install the latest LTS version.

For installation instructions of npm, see https://docs.npmjs.com/downloading-and-installing-node-js-and-npm.

Get Magnolia CLI

Run the following command in a shell to install Magnolia CLI:

  • Mac or Linux

  • Windows

sudo npm install @magnolia/cli -g
npm install @magnolia/cli -g (1)
1 Depending on your permissions and the location where you have installed Node.js, you may have to execute the command above with root permissions. Without installation permissions you will notice messages such as npm ERR! in the shell.

Once you have installed Magnolia CLI, test the installation by running the following command in the shell:

mgnl help

Downloading Magnolia

Let’s assume that the directory where you intend to download and install Magnolia is called magnolia.

  1. Change to this directory and open a shell.

  2. Enter the following command, where with <version> you may specify the Magnolia release you wish to download.
    (If you don’t specify the version and run the command without the -m switch, CLI will download the latest release of the most recent Magnolia branch.

    mgnl jumpstart -m <version>
  3. When prompted to choose templates, enter:

    • 2 for the demo-webapps template,

    • followed by either:

      • 1 for the magnolia-community-demo-webapp or

      • 2 for the magnolia-dx-core-demo-webapp, provided you got a valid Magnolia license.

The jumpstart command:

  • Downloads the Magnolia bundle specified into the magnolia directory.

  • installs and configures CLI v5.

  • Creates a light-modules folder in the directory.

  • Changes the default value of the magnolia.resources.dir configuration property from ${magnolia.home}/modules to /magnolia/light-modules for both the Author and the Public instances of Magnolia.

Once the setup operation is complete, you should see a message similar to this one:

info: Project successfully downloaded
info: Run "npm run mgnl" to see the list of registered commands
info: Start the project using: "npm run mgnl -- start"
info: If the "StartPlugin" is not available, install it using: "npm run mgnl -- add-plugin @magnolia/cli-start-plugin"
info: For additional plugins and features, refer to the Magnolia CLI documentation: https://docs.magnolia-cms.com/magnolia-cli

Starting Magnolia

In the parent directory of light-modules, enter:

npm run mgnl -- start

The command starts Magnolia. This is complete when you see a message like Server startup in 112737 milliseconds. You can then access the UI of the Author instance.

Logging into the Author instance

Go to http://localhost:8080/magnoliaAuthor and log in to the Author instance as a superuser :

  • Username: superuser

  • Password: superuser

When you log in, the first page you see is the App Launcher, in which you can see groups of apps:

App launcher with grouped apps

Congratulations. Magnolia is now installed and running.

Feedback

DX Core

×

Location

This widget lets you know where you are on the docs site.

You are currently perusing through the DX Core docs.

Main doc sections

DX Core Headless PaaS Legacy Cloud Incubator modules