JavaScript dependencies

Install dependencies

To install dependencies, you can add them to your script's package.json using standard npm or yarn commands:
bash
Copied
1
# Example installing the airplane SDK
2
npm install airplane
You should place your package.json file either next to your task or in a parent directory. The closest directory containing a package.json becomes the root of your project.
Airplane skips installation of devDependencies—if your application requires devDependencies, you can override the install command. See Custom build steps.

Private npm packages

To install private packages from NPM, you'll need to generate an access token with read-only permissions. Add it as a Config Var and set it as an environment variable in your airplane.yaml configuration file called BUILD_NPM_TOKEN:
yaml
Copied
1
# airplane.yaml
2
javascript:
3
nodeVersion: "18"
4
envVars:
5
BUILD_NPM_TOKEN:
6
config: BUILD_NPM_TOKEN
Build-time environment variables like BUILD_NPM_TOKEN will only be applied if included in the airplane.yaml configuration file.

Other private packages

If you're using other private registries like GitHub packages, you can upload the entire contents of your .npmrc file as a config variable (assuming the tokens are stored there) and set the BUILD_NPM_RC environment variable:
Upload .npmrc as a config variable.
Copied
1
// .npmrc
2
//registry.npmjs.org/:_authToken=TOKEN_FOR_NPM
3
//npm.pkg.github.com/:_authToken=TOKEN_FOR_GITHUB
bash
Copied
1
cat .npmrc | airplane configs set --secret npmrc
Set the BUILD_NPM_RC environment variable in your airplane.yaml configuration file.
yaml
Copied
1
# airplane.yaml
2
javascript:
3
nodeVersion: "18"
4
envVars:
5
BUILD_NPM_RC:
6
config: npmrc

npm/Yarn workspaces

By default, the airplane CLI will find the nearest package.json to determine the root directory of your project.
If you are using npm or yarn workspaces, you must tell Airplane where to find the root of your workspace. See Yarn and npm workspaces for instructions.