INSTALLATION / NPM

Installation with NPM

Use this guide when P2LRN is part of a project that manages its dependencies with NPM. Each package has a different function and you can install only the ones you need.

1. Packages available

@p2lrn/player

Play courses .p2lrn and exposes Host Adapter, capabilities, collaboration, offline/cache and browser analytics.

@p2lrn/studio

Integrate the visual editor. Use @p2lrn/player for the preview.

@p2lrn/toolkit

Authoring, Reader, validation, Reference Host and Node.js/TypeScript tools.

@p2lrn/analytics

Dashboard and aggregation for learners, courses, progress, activity, attempts and authoritative notes.

@p2lrn/h5p-libraries

Optional corpus of reusable H5P libraries for content that does not include its entire closure.

The five packages in the current prerelease are aligned in 0.5.0-alpha.11 and are published under the dist-tag next. The examples use the exact version to avoid resolving another channel by accident.

2. Install the Player

Install the package and then import it once from your app code.

Terminal
npm install @p2lrn/player@0.5.0-alpha.11
JavaScript / TypeScript
import '@p2lrn/player';
HTML
<p2lrn-player src="/courses/course.p2lrn"></p2lrn-player>

After the import, the element <p2lrn-player> is available on the page.

3. Install Studio

Studio uses Player as a dependency of the browser environment, so both must be available in the same application.

Terminal
npm install @p2lrn/studio@0.5.0-alpha.11 @p2lrn/player@0.5.0-alpha.11
JavaScript / TypeScript
import '@p2lrn/studio';

4. Install the Toolkit

Install Toolkit when you need to create/process packages, Document Reader, or Authoritative Reference Host from Node.js/TypeScript.

Terminal
npm install @p2lrn/toolkit@0.5.0-alpha.11

Toolkit requires Node.js 22 or later. Player and Studio declare Node.js 18 or later for their package tools.

5. Install Analytics

Analytics is independent of Studio and Player: it only needs the authorized dataset delivered by your Host.

Terminal
npm install @p2lrn/analytics@0.5.0-alpha.11

6. Install shared H5P libraries (optional)

Not all courses need them. Install them when a .h5p real depends on libraries that do not travel within the file itself.

Terminal
npm install @p2lrn/h5p-libraries@0.5.0-alpha.11

The runtime can resolve that catalog from the configured library host. An absent library is not invented: loading fails explicitly.

7. Check that the integration is ready

After installing and importing a component, open the page where you installed it and verify two things: that the element registers without JavaScript errors and that it can access the file .p2lrn specified in src. If the package is in another source, the server hosting it must allow it to be read from the browser.

8. Choose what to install

Just play

Install @p2lrn/player.

Edit visually within your app

Install @p2lrn/studio and @p2lrn/player.

Create or process courses on the server

Install @p2lrn/toolkit.

learner and course panel

Install @p2lrn/analytics.

H5P with external libraries

Duck @p2lrn/h5p-libraries only when those dependencies are not embedded.

9. Next step

If you just need to play, continue with Player. If you are going to integrate the editor, follow the Studio guide with NPM. For authoring by code, continue with Toolkit.