JetBrains Space Help

Get npm Packages in Unity

Unity is a game-development environment that is used to create 2D and 3D games and deploy them on multiple platforms. Unity uses npm packages to distribute various types of features and assets. You can use an npm registry in Space to store and share Unity packages. Creating such a registry and publishing packages is the same as for the ordinary npm registry.

To use an npm package in a Unity project

  1. Log in to the npm registry:

    npm login --registry

    • is the registry URL

    • mycompany is the name of your company in Space, mynpm is the registry name.

    If you are not sure about the URL, you can copy the URL of a particular npm registry on the Packages page.

  2. When asked for credentials, specify your Space username and password. npm uses permanent tokens for authentication. Once you log in to the registry, Space will automatically create a permanent token specifically for accessing the npm registry. This token will be saved in your local .npmrc configuration file . You can manage the created token on the My Profile | Security | Personal Tokens page.

    Automatically generated token for an npm registry
  3. Open the Packages directory in the Unity project root and then open the manifest.json

  4. Add the registry and the package dependency to manifest.json. For example, we want to reference the my.unity.package:1.2.3:

    { "scopedRegistries": [ { "name": "space", "url": "", "scopes": [ "my.unity" ] } ], "dependencies": { "my.unity.package": "1.2.3", // other dependencies go here } }
  5. If the npm registry is private (in registry settings, Access is set to Private), you should provide Unity the authentication token for repository access (see step 2). Open the Unity Package Manager configuration file:

    • Windows: %USERPROFILE%/.upmconfig.toml

    • macOS and Linux: ~/.upmconfig.toml

    If the file doesn't exist, create it.

  6. Add the registry URL and the authentication token to upmconfig.toml. For example:

    [npmAuth.""] token = "eyJhbGciOiJSUzUxMiJ9..." email = "" alwaysAuth = true
  7. Open the Unity project in the Unity Editor. Unity must download the package and show it in the Package Manager.

    npm Unity package
Last modified: 23 November 2022