CLI Installation
This tutorial guides you through installing @criticalmanufacturing/cli, including prerequisites, installation steps, and validation.
1. Prerequisites
Node.js and NPM
Before you begin, ensure you have the following software installed:
- Node.js;
- NPM command line interface.
Node.js Version Compatibility
@criticalmanufacturing/cli works with the latest Node.js version. However, specific scaffolding commands require compatibility with your target CM MES version:
| CM MES Version | Required Node.js Version | Required NPM Version |
|---|---|---|
| v8.x or v9.x | v12.x (Erbium) | v6.x |
| v10.x | v18.x (Hydrogen) | v9.x |
| v11.x or later | v20.x (Iron) or later | v10.x or later |
Installing Node.js and NPM
Use NVM
Use a Node version manager like nvm to install Node.js and NPM.
Avoid the usage of Node installer, since it usually installs npm in a directory with local permissions, which may cause permissions errors when you run npm packages globally.
To perform the checks or install Node.js and NPM dependencies:
- Adapt the following PowerShell script;
-
Run it on a command line with administration privileges.
#SET TARGET MES MAJOR VERSION (8, 9, 10 or 11) $mesMajorVersion = 11 #Map MES to node version $nodeMajorVerion = switch ($mesMajorVersion) { 8 { "12" } 9 { "12" } 10 { "18" } 11 { "20" } } # To check installed versions of Node.js and NPM use: nvm list # If not found, install them nvm install $nodeMajorVerion #Determine the installed version $newNodeVersion = nvm list $newNodeVersion = $newNodeVersion | where-object { $_ -Match "\s$nodeMajorVersion\." } | Select-Object -First 1 $newNodeVersion = ($newNodeVersion | Select-String -Pattern "\d+\.\d+\.\d+").Matches.Value # Set appropriate node version as active nvm use $newNodeVersion # Check the active node.js version node -v # Check the active NPM version npm -v
IoT Driver Dependencies (Optional)
The development of IoT drivers on Critical Manufacturing MES has a dependency for the node-gyp NPM package. As so, if your project requires the development of custom driver, ensure that your dev/build environment has its dependencies previously installed (check its GitHub Page for details).
2. Install CLI
NPM allow-scripts requirement
Recent NPM versions may block install-time scripts by default as a
security measure. Since @criticalmanufacturing/cli relies on install
scripts, the installation can fail or complete incompletely unless the
package is explicitly allowed to run them. The first command below
allows the package's install scripts before installing.
- Open a command line with administration privileges.
-
Execute the commands:
npm config set allow-scripts=@criticalmanufacturing/cli --location=user npm install -g @criticalmanufacturing/cli
3. Validate
- Open a command prompt.
-
Run the following command to verify the installation:
cmf -v
This command should output the installed version of @criticalmanufacturing/cli if successful.