The npm plugin is useful when working with Node.js and npm JavaScript based parts.
This plugin can only be used with a base of core22
and core20
. For core18
and core
, use the nodejs plugin instead.
The plugin uses node to install dependencies from package.json
. It also sets up binaries defined in package.json
by adding them to PATH
.
This plugin uses the common plugin keywords as well as those for “sources”. For more information, see Snapcraft parts metadata.
Plugin-specific features and syntax are dependent on which base is being used, as outlined below:
See Node applications for a simple example, or search GitHub for projects already using the plugin.
This is a snapcraft plugin. See Snapcraft plugins and Supported plugins for further details on how plugins are used.
This plugin uses the following plugin-specific keywords:
npm-include-node
(bool, default: false)
If true, download and include the node binary and its dependencies. If npm-include-node
is true, then npm-node-version
must be defined.
npm-node-version
(string)
The version of node.js you want the snap to run on and includes npm, as would be downloaded from (https://nodejs.org). If not set, node.js must be provided another way, such as creating a node-deps
part that provides node using build and staging dependencies or manually. Search GitHub for examples.
Requires Snapcraft version 8.0+ for core24
.
Requires Snapcraft version 7.0+ for core22
.
This plugin uses the following required plugin-specific keyword:
npm-node-version
(string)
The version of node.js you want the snap to run on and includes npm, as would be downloaded from (https://nodejs.org).Requires Snapcraft version 4.0+.
Last updated 7 months ago.