Movatterモバイル変換


[0]ホーム

URL:


ContentsMenuExpandLight modeDark modeAuto light/dark, in light modeAuto light/dark, in dark modeSkip to content
Snapcraft 8.14.1 documentation
Snapcraft 8.14.1 documentation
Back to top

Craft a Node app

This how-to guide covers the steps, decisions, and implementation details thatare unique when crafting a Node-based snap. We’ll work through the aspectsunique to Node apps by examining an existing project.

The process of developing a snap for a Node app builds on top of npm andpackage.json manifests, making it possible to adapt or integrate an app’sexisting build tooling into the crafting process.

Example project file for wethr

The following code comprises the project file of a Node tool,wethr. This project is a CLI tool for obtaininglocal weather information.

wethr project file
snapcraft.yaml
name:wethrversion:gitsummary:Command line weather tool.description:|Get current weather:-$ wethrGet current weather in metric units$ wethr --metricGet current weather in imperial units$ wethr --imperialconfinement:strictbase:core20apps:wethr:command:bin/wethrparts:wethr:source:.plugin:npmnpm-node-version:14.16.1

Add a part written in Node

snapcraft.yaml
parts:wethr:source:.plugin:npmnpm-node-version:14.16.1

Node parts are built with theNPM Plugin.

To declare a Node part:

  1. Declare the general part keys, such assource,override-build,build-packages, and so on.

  2. Setplugin:npm.

  3. Determine how npm is added to the snap:

    • If you want Snapcraft to download and pack npm, setnpm-include-node:true, and then setnpm-node-version tothe required NPM version.

    • If you’d rather manually pack npm into the snap, don’t set either ofthese keys. Instead, manually include a copy of npm in the files, anddeclare it in another part.

Contents

[8]ページ先頭

©2009-2026 Movatter.jp