Supported versions
You can select the major version. But the latest compatible minor version is applied automatically and can’t be overridden. Patch versions are applied periodically for bug fixes and the like. When you deploy your app, you always get the latest available patches.Specify the language
To use Node.js, specifynodejs as your app’s type:
For example:
To use a specific version in a container with a different language, use a version manager.
Usage example
To use JavaScript with Node.js on Upsun, configure your app configuration (a complete example is included at the end).1. Specify the version
Choose a version from the list of supported versions and add it to your app configuration:2. Specify any global dependencies
Add the following to your app configuration: These are now available as commands, the same as installing withnpm install -g.
3. Build your app
Include any commands needed to build and setup your app in thehooks, as in the following example:
4. Start your app
Specify a command to start serving your app (it must be a process running in the foreground):5. Listen on the right port
Make sure your Node.js application is configured to listen over the port given by the environment.Complete example
A complete basic app configuration looks like the following:Dependencies
By default, Upsun assumes you’re using npm as a package manager. If your code has apackage.json, the following command is run as part of the default build flavor:
.npmrc file in your app root.
Use Yarn as a package manager
To switch to Yarn to manage dependencies, follow these steps:- Turn off the default use of npm:
-
Specify the version of Yarn you want:
package.json
- Yarn 3.x and Node.js 16+
- Yarn 3.x and Node.js 14
- Yarn < 3
- Use Corepack to run Yarn in your build hook:
Use Bun as a package manager
To switch to Bun to manage dependencies, use the following configuration:.upsun/config.yaml
Use Bun as a runtime
You can even use Bun as a runtime by adjusting thestart command as follows:
.upsun/config.yaml