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/playerPlay courses .p2lrn and exposes Host Adapter, capabilities, collaboration, offline/cache and browser analytics.
@p2lrn/studioIntegrate the visual editor. Use @p2lrn/player for the preview.
@p2lrn/toolkitAuthoring, Reader, validation, Reference Host and Node.js/TypeScript tools.
@p2lrn/analyticsDashboard and aggregation for learners, courses, progress, activity, attempts and authoritative notes.
@p2lrn/h5p-librariesOptional 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.
npm install @p2lrn/player@0.5.0-alpha.11import '@p2lrn/player';<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.
npm install @p2lrn/studio@0.5.0-alpha.11 @p2lrn/player@0.5.0-alpha.11import '@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.
npm install @p2lrn/toolkit@0.5.0-alpha.11Toolkit 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.
npm install @p2lrn/analytics@0.5.0-alpha.116. 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.
npm install @p2lrn/h5p-libraries@0.5.0-alpha.11The 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
Install @p2lrn/player.
Install @p2lrn/studio and @p2lrn/player.
Install @p2lrn/toolkit.
Install @p2lrn/analytics.
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.