Build commands
Published
Updated
composer install; npm run build
Build commands prepare the code for production during each deployment, before it goes live, such as composer install and npm run build. The software template and the stack detector set them, and they can be changed per environment.
When the repository contains a deploy file, this setting is managed there and cannot be edited in the dashboard.
How build commands work
Build commands run in the deployment container, after the code is pulled from Git and before anything reaches the environment. The code and the build results together form the package that the deployment puts into the storage. When a build command fails, the deployment stops and the environment keeps the previous code.
Commands run in order from the Git repository root. Use cd to change directory for that and all following commands.
Automatic configuration
When an app or environment is created, the stack detector reads the repo and sets the deployment settings, combined with the software template. The basic build commands it sets:
- With a
composer.json:composer install --no-dev --prefer-dist --no-interaction --no-ansi --no-progress - With a
package.json:installandrun buildwith the detected package manager, npm, pnpm or yarn
Manually editing build commands
Build commands are part of the deployment settings of each environment in the dashboard.
Composer build commands
PHP frameworks and CMS install as Composer dependencies, and the vendor folder stays out of Git. Composer is installed in the build, so a build command installs the dependencies from composer.lock, see Composer. The default:
composer install --no-dev --prefer-dist --no-interaction --no-ansi --no-progress
Node.js build commands
JavaScript and CSS build tools, such as Vite, run in the build. They create the bundles the app serves:
npm install
npm run build
Node.js version
Set the Node.js version per environment. Available versions:
| Node.js version | End of life |
|---|---|
| Node.js 24 (default) | 2028 |
| Node.js 22 | 2027 |
Keep node_modules out of the deployment
The node_modules folder is a cached directory: it stays in the build between deployments, so npm install doesn't download everything again. The app rarely needs it at runtime. Most software templates set /node_modules as an exclude pattern, so it doesn't land in the web storage. Check that pattern when the app was set up without a template. Adding the pattern later doesn't remove a copy that was deployed before.
Approve install scripts with npm 12
npm 12 blocks the install scripts of dependencies until they are approved. Some packages fetch or link their native binary in such a script, and the build then fails, for example with lightningcss: line 1: This: command not found. Approve those packages with npm 12 and commit the allowScripts block it writes to package.json:
$ npm install-scripts approve --no-allow-scripts-pin lightningcss-cli
Without --no-allow-scripts-pin, the approval is pinned to the installed version, and the next update of the package fails again.
When the build already failed, purge the cached directories once after committing the approval. The failed build left the package in the cached node_modules folder without its binary, and npm install skips it until its version changes.
Limits of the build
npm installalso installs thedevDependencies, where build tools like Vite usually sit.- npm and pnpm are installed, yarn and Bun are not. Install them as project dependencies first, for yarn with
npm i yarnbeforeyarn install. Bun also needs its install script approved. - Global installs with
npm install -gfail. Install tools as project dependencies instead:./node_modules/.binis in thePATHof the build commands. - Only known binaries can run. Headless browsers, like the one Playwright downloads, can't start.