NAME
Mojo::Alien::npm - Runs the external nodejs program npm
SYNOPSIS
use Mojo::Alien::npm;
my $npm = Mojo::Alien::npm->new;
$npm->init;
$npm->install;
DESCRIPTION
Mojo::Alien::webpack is a class for runnig the external nodejs program npm.
ATTRIBUTES
binary
$array_ref = $npm->binary;
$npm = $npm->binary(['npm']);
The path to the npm executable. Default is "npm" unless the MOJO_NPM_BINARY
environment variable has been set. This can also be set to "pnpm" in case you prefer https://pnpm.io/.
config
$path = $npm->config;
$npm = $npm->config(path->to_abs->child('package.json'));
Holds an /absolute path to "package.json".
mode
$str = $npm->mode;
$npm = $npm->mode('development');
Should be either "development" or "production". Will be used as "NODE_ENV" environment variable when calling "npm".
METHODS
dependencies
$dependencies = $npm->dependencies;
Used to get dependencies from "config" combined with information from npm ls
. The returned hash-ref looks like this:
{
"package-name" => {
required => $str, # version from package.json
type => $str, # dev, optional or prod
version => $str, # installed version
...
},
...
}
init
$npm->init;
Used to create a default "config" file.
install
$npm->install;
$npm->install('package-name');
$npm->install('package-name', {type => 'prod', version => '0.1.2'});
Installs either all modules from "config" or a given package by name. An additional $info
hash can also be provided.