What is npm?
npm is a package manager for JavaScript that helps developers install, share, and manage libraries or pieces of code that are commonly used in applications. These packages can range from small utility functions to full-fledged UI components like buttons, form elements, or even complex layouts.
npm is also a key enabler of the design-development collaboration that UXPin Merge facilitates. By packaging React components through npm, developers can hand off real, functioning UI components to designers, who can then integrate them into their designs effortlessly. This results in a more consistent and efficient workflow, ensuring that your design system and the final product are perfectly aligned.. Discover UXPin Merge.
What is NPM (Node Package Manager)?
npm or Node Package Manager is an open-source repository of tools engineers use to develop applications and websites.
npm is two things:
- A repository for publishing open-source projects.
Simplified version: a digital storage and retrieval facility. - A command-line interface (CLI) for interacting with the repository.
Simplified version: a tool to communicate with the storage facility.
What is a Package Manager?
Before we can explain what npm package is, it’s essential to understand the idea of a package manager. Think of a package manager as a toolkit for developers.
Let’s say you’re building an application that uses Stripe for payments. A package manager installs all the code your product will need to communicate with Stripe and process payments.
Instead of writing all that code or copy/pasting it from Stripe’s docs, engineers simply enter a command, and the package manager installs the code dependencies they need from Stripe.
There are millions of these packages for everything you can think of to develop an application–like different types of search functionality, APIs, payments, authentication tools, maps, icons, hosting, and more.
You get public open-source repositories (like npm) where anyone can upload and install packages, as well as private package repositories with restricted access.
What is a Command Line Interface?
A command-line interface (CLI) is a text interface developers use to interact with computer programs. This CLI allows you to execute commands to run background operations necessary for software development.
In the case of npm, the CLI allows you to interact with the package registry. For example, engineers can use commands like npm install followed by the package name to install a specific package.
The npm Registry
The npm website is where engineers can search and learn about packages. This website is just a registry and doesn’t host the packages. Instead, engineers use platforms like GitHub, Packagecloud, AWS CodeArtifact, and others to host and distribute packages.
For example, if we look at the UXPin Merge CLI on NPM, it has displays GitHub as the repository and relevant link. Above that is the command to install the UXPin Merge CLI and its dependencies: npm i @uxpin/merge-cli. The “i” after npm is an abbreviation for “install.” So, typing npm install @uxpin/merge-cli would render the same result.
What are Dependencies?
Packages consist of other packages that engineers call dependencies–we know, confusing, right! These dependencies are packages of code that perform different tasks within the project.
For example, the UXPin Merge CLI uses Typescript and therefore requires the typescript package as a dependency. Typescript is just one of the 41 dependencies UXPin Merge CLI requires.
What are Devdependencies?
Looking at the UXPin Merge CLI’s dependencies, you’ll notice 41 Dependencies and 41 Dev Dependencies (also referred to as devDependencies–one word).
- Dependencies: The packages required to run a piece of software
- Dev Dependencies: The packages needed during the development phase only
Dependencies and devDependencies reside in a separate folder called node_modules, so your packages.json file and project code know where to find them.
What is the package.json File?
There’s a package.json file that provides its metadata and dependencies. When installing the project on your computer, npm will reference the package.json file to install the dependencies and devDependencies.
Instead of installing each dependency individually, you simply type npm install in the command line.
Hosting providers also use the package.json file to install the dependencies (excluding devDependencies) needed to run the project on its servers.
What is package-lock.json?
The package-lock.json specifies the exact version of the package used to build the project. This file locks the dependencies so that when the project is installed, it references the versions used during development rather than the latest release.
Engineers update packages regularly, often changing the way the package works. So, locking your dependencies ensures the project operates as intended.
How to use npm
Here are some common npm commands and what they do:
- npm init: Creates a package.json file for your project. If you’re building an application from scratch, npm init will be one of the first commands you use to include key project information. NPM will automatically update your package.json file whenever you install or remove packages.
- npm install: Installs all of the project dependencies in a package.json file.
- npm install <package-name>: Installs a specific package from the NPM registry and saves it to your node_modules folder. For example, npm install @uxpin/merge-cli will install the Merge CLI.
- npm install <package-name> –save: Installs an NPM package and adds it to the dependencies in your package.json file.
- npm install <package-name> –save-dev: installs an NPM package and adds it to the devDependencies
- npm uninstall <package-name>: Uninstalls a specific package from your project.
- npm doctor: Runs diagnostics on your npm installation to check if it has everything it needs to manage your packages.
- npm update <package-name>: Updates a specific package to the latest version.
These are just a few of the most common npm commands. You can find the complete list in the npm documentation.
Understanding npm as a Designer
npm is simply a toolkit comparable to plugins or app extensions for design tools. You don’t need to know the ins-and-outs of how packages are created, but it may be useful to know a thing or two about it.
First of all, some of code component libraries are shared as npm packages, such as MUI, Ant Design, etc.
How to find component libraries that are distributed as npm packages? Let’s say you search through Adele, UXPin’s library of publicly available Design Systems, for a component library that you can bring in to UXPin. You pick Shopify’s Polaris and notice that it is distributed via npm.
So, you go to the NPM site, look for Shopify’s Polaris, and find it.
UXPin with Merge technology allows you to import UI elements from component libraries via NPM packages. Then, you can use those elements to put together fully-functional prototypes.
UXPin Merge is usually being set up by a developer. But if you lack the development support, you can use our new tool – Merge Component Manager and manage UI components by yourself.
However, if you want to enhance your programming knowledge to collaborate with devs better, then learning about basic code principles (HTML, CSS, Javascript) and component libraries is far more valuable for designers.
What Can You Do with npm Integration?
Even though npm is typically a tool developers use, it plays a crucial role in enabling powerful design workflows—like bringing React components into UXPin for seamless drag-and-drop UI building.
Here’s why npm is important for technical designers working with tools like UXPin Merge:
- Access to React Components: If your design system is built using React, npm allows you to package these components and make them accessible for use in other applications or tools—like UXPin Merge. React components that are available as npm packages can be directly imported into UXPin, giving designers the ability to drag and drop real code components into their designs without writing code.
- Easily Manage Updates: npm simplifies version control. When a developer updates a package (such as a new version of a button component), npm can automatically manage this update in UXPin Merge, ensuring that designers always work with the latest components from the development team. This ensures consistency between design and development without the need for manual updates.
- Collaborate Seamlessly with Developers: npm helps technical designers and developers work from the same source of truth. Developers use npm to publish the components they create, while designers can easily import those components into UXPin using Merge. This ensures that the components designers use for prototyping are exactly the same as the ones developers will implement in the final product.
Improve Collaboration With UXPin Merge
Merge enhances collaboration between design and development because designers and engineers work with the same component library.
Instead of having a UI kit for designers and code for devs, Merge syncs a repository to UXPin’s editor so design teams can build fully functioning prototypes using code components.
You can sync your company’s design system or a component library like MUI so that you only have to drag and drop UI elements to build interfaces. Request access to Merge.
Use a single source of truth for design and development. Discover Merge