Init command for project initialization
The init command initializes a Magnolia CLI project in your current directory.
It automatically detects your project type and configures the necessary files and dependencies.
Running the command
In your project directory, run:
npx @magnolia/cli@latest init
The command does the following steps:
-
Detect the project type.
-
Create or validate the
package.jsonwith"type": "module". -
Install the
@magnolia/clias a dependency. -
Add the
"mgnl": "node node_modules/@magnolia/cli"script. -
Create the
mgnl.config.js(ormgnl.config.mjs, for CommonJS projects), -
For Headless Accelerator projects: Run
ha installif available.
For Headless Accelerator projects, ensure that the ha-cli and ha commands are installed.
For more details, see the HA Documentation.
|
| If your project has already been initialized, the command detects this and exits without making any changes. |
Next steps
After the initialization:
-
Browse the available plugins to find the ones you need.
-
Add plugins:
npm run mgnl — add-plugin <plugin-name>. -
Run CLI commands as needed.
Troubleshooting
Fixing errors
| Error type | How to fix |
|---|---|
Invalid |
Fix the syntax errors before running the |
|
Review and fix import or syntax errors in your config file. |
Headless Accelerator setup failures |
Run |