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:
- Scaffold new Power Apps code apps from scratch
- Develop and test apps locally before deployment
- Push and publish apps to your Power Platform environment
- Integrate app development into CI/CD pipelines
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:
- Node.js (version 16 or later) — Download here
- npm (version 8 or later, bundled with Node.js)
- A valid Microsoft Power Platform environment with maker permissions
- Power Apps per-app or per-user licence assigned to your account
- Basic familiarity with command-line tools and JavaScript/TypeScript
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:
/src— Your app's source files/assets— Images, icons, and static resourcesapp.json— App manifest and configurationpackage.json— npm dependencies and scripts
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
- Use source control: Commit your project to Git from day one. The npm CLI project structure is version-control friendly.
- Automate deployments: Pair the npm CLI with Power Automate pipelines or Azure DevOps for CI/CD workflows.
- Test in a sandbox first: Always validate new code apps in a non-production environment before releasing to end users.
- Stay updated: As this is a preview feature, check the npm package page regularly for updates and breaking changes.
- Leverage TypeScript: The CLI supports TypeScript out of the box — strongly typed code apps reduce runtime errors significantly.
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:
- Explore advanced Power Platform development patterns for enterprise-grade apps
- Integrate your code app with Dataverse and Dynamics 365
- Automate business processes triggered by your app using Power Automate flows
- Upskill your team with our Power Platform training programmes
🚀 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.
- ✅ Expert Power Platform development
- ✅ End-to-end Dynamics 365 implementation
- ✅ Hands-on developer training programmes
📩 Get in touch with our team today — let's talk about how we can help you build smarter, faster Power Apps solutions.