Power Apps npm CLI Quickstart: Build a Code App from Scratch (2024 Preview Guide)

Power Apps npm CLI Quickstart: Build a Code App from Scratch (Preview)

Are you ready to accelerate your Power Apps development workflow? With the new npm CLI for Power Apps (currently in preview), developers can now create, build, and deploy code apps directly from the command line — no more switching between tools or clunky manual deployments. This guide walks you through everything you need to get started in minutes.

Whether you're a seasoned developer or new to the Power Platform development ecosystem, this quickstart will have you building your first code app from scratch using the npm CLI.

⚠️ Preview Notice: The Power Apps npm CLI is currently in public preview. Features and commands may change before general availability. Use in production environments at your own discretion.

What Is the Power Apps npm CLI?

The Power Apps client library for code apps (available via npm as @microsoft/power-apps, version 1.0.4+) is a command-line interface that enables developers to:

This is a significant step forward for professional developers who prefer code-first workflows. Learn more about how this fits into our broader Power Platform development services.

Prerequisites

Before you begin, make sure you have the following installed and configured:

Not sure if your environment is set up correctly? Our Power Platform consulting team can help you get your tenant ready.

Step 1: Install the Power Apps npm Package

Open your terminal or command prompt and run the following command to install the Power Apps CLI globally:

npm install -g @microsoft/power-apps

Once installed, verify the installation was successful:

pac --version

You should see the installed version number returned in your terminal.

Step 2: Authenticate with Your Power Platform Environment

Before creating or deploying apps, you need to authenticate the CLI with your Microsoft account and target environment:

pac auth create --url https://yourorg.crm.dynamics.com

Follow the browser prompts to complete authentication. Once connected, you can verify your active profile:

pac auth list

Step 3: Create a New Code App

With authentication in place, scaffold a new code app using the init command:

pac power-fx init --name MyFirstCodeApp

This creates a new project folder with the following structure:

Step 4: Develop Your App Locally

Navigate into your project directory and install dependencies:

cd MyFirstCodeApp
npm install

Start the local development server to preview your app in real time:

npm start

Your app will be available at http://localhost:3000. Changes to source files will hot-reload automatically, giving you a fast and efficient development loop.

Step 5: Build and Deploy to Power Platform

When you're happy with your app, build the production bundle:

npm run build

Then push the app to your Power Platform environment:

pac solution push

Once uploaded, your app will appear in the Power Apps maker portal where you can publish it for users.

Tips and Best Practices

Troubleshooting Common Issues

Authentication Errors

If pac auth create fails, ensure your account has the System Customizer or Environment Maker security role in the target environment. You may also need to clear existing auth profiles with pac auth clear before re-authenticating.

npm Install Failures

Ensure you're running Node.js 16 or later. Run node --version to check. If you encounter permission errors on macOS/Linux, avoid using sudo — instead, configure npm to use a local prefix directory.

App Not Appearing After Push

Confirm the correct environment is selected with pac env list and pac env select. The app may also need to be manually published from the maker portal after the initial push.

What's Next?

Now that you've created your first code app using the Power Apps npm CLI, here are some natural next steps to deepen your skills:


🚀 Ready to Build Better Power Apps, Faster?

The npm CLI is just one piece of the puzzle. At CRMONCE, our certified Power Platform specialists help businesses design, develop, and deploy professional-grade Power Apps solutions — from rapid prototypes to enterprise rollouts.

📩 Get in touch with our team today — let's talk about how we can help you build smarter, faster Power Apps solutions.