Walkthrough: Serializing with NuGet and npm

Current version: 10.1

You can use package referencing (NuGet and/or npm) to import serialized items into your solution.

This walkthrough describes how to:

  • Create a package

  • Create a NuGet package

  • Create an npm package

  • Add a package reference

Create a package

To create a package containing Sitecore serialization:

  1. Add a sitecore.json file in the package root. This file contains a modules property pointing to serialization modules files.


    Module files are not organized in a specific way in the package to accommodate different patterns.

    An example of the package structure:

    • Root

      • sitecore.json

      • modules

        • items/*/*.module.json

        • npm:./packageSrc/npm-resource-package

        • nuget:Sitecore.DevEx.NuGetResourcesExample@1.0.0

    An example of the sitecore.json file:

      "modules": [

    An example of a module file named Sitecore.DevEx.NuGetResourcesExample.module.json:

      "namespace": "Sitecore.DevEx.NuGetResourcesExample",
      "description": "Content serialization example",
      "items": {
        "includes": [
            "name": "Content",
            "path": "/sitecore/content/home"
  2. To check that you set up the package correctly, run the following command:

    dotnet sitecore serialization info

    You set up the package successfully if the command returns the following message:

    Content serialization example
        Content: /sitecore/content/home

Create a NuGet package

After you have added the sitecore.json file in the package root, you can create a NuGet package.

To create a NuGet package containing Sitecore resources:

  1. Add the PackageName.nuspec file to define the package, for example:

    <?xml version="1.0"?>
    <package >
        <description>Example NuGet package containing Sitecore resources</description>
        <!-- the sitecore.json and modules and items must be copied to the package -->
        <file src="NuGetResourcesExample\sitecore.json" target="" />
        <file src="NuGetResourcesExample\sitecore\**" target="sitecore" />

    There is no specific location for the PackageName.nuspec file in your project, as long as the file paths are relative to it.

  2. Add any Sitecore resource files that you want to package (module files or serialized items) in the files section of the PackageName.nuspec file.

  3. To build the package, run nuget pack and push it to the NuGet feed of your choice.

Create an npm package

After you have added the sitecore.json file in the package root, you can create a npm package.

To create an npm package containing Sitecore resources:

  1. Add the package.json file to define the package, for example:

      "name": "npm-example-package",
      "version": "1.0.0",
      "description": "Sample of providing SIC resources via npm"
  2. Open the .gitignore or .npmignore files to check that they do not ignore the resources you want to include automatically in the npm package.


You do not have to build most npm packages before publishing them to the package repository of your choice.

Add a package reference


To use package references, you must have nuget or npm available as a command on your PATH to install the packages during Sitecore CLI operations.

To add a package reference to your solution:

  • In the sitecore.json file, in the modules property, add an entry for either:

    • nuget:<packagename>

    • npm:<packagename>

    For example:

    "modules": [
      "npm:my-other-package@0.2.0", // version specs allowed per npm install
      "npm:./path/to/local/package", // local package on filesystem
      "nuget:Organization.MyOtherPackage@2.1.1", // version specs allowed. No wildcards.

    NuGet package references install using registered package sources on your machine. To specify a custom package source, you can create a NuGet.config file at the root of your repository that contains any custom feeds to resolve your package references.

    For further information, see Extend the Command Line Interface with NuGet.

After a package reference is registered, it is automatically installed and parsed for modules during any Sitecore CLI operation that uses modules. You can check the module installation with sitecore ser info or sitecore ser push. Updating modules is automatic based on any version specifications.

Do you have some feedback for us?

If you have suggestions for improving this article,