Install Node.js, Yarn & pnpm
In order to run the default Anchor project test file, which is written in TypeScript, you will need Node.js and Yarn. By default, when you create a new Anchor project using the anchor init
command, it generates a TypeScript-based test suite. Alternatively, if you prefer a Rust-based test setup, you can specify it during initialization with anchor init --test-template rust
.
Node.js Installation
The recommended method for installing Node.js is by using the Node Version Manager (nvm). This allows you to manage different Node.js versions easily, which is especially helpful when working on multiple projects with different Node.js version requirements.
Install nvm by running the following command in your terminal:
After the installation, restart your terminal for the changes to take effect.
Verify that
nvm
was installed correctly by running:Once
nvm
is confirmed to be installed, use it to install the latest version of Node.js by running:Verify the Node.js installation by checking the version:
You should see output similar to:
Yarn and pnpm Installation
Once Node.js is installed, the next step is to install Yarn, which is a package manager commonly used with JavaScript and TypeScript projects. You can do this by running:
You can verify that Yarn was successfully installed by checking its version:
You should see output similar to:
You can install pnpm by running:
You can verify that pnpm was successfully installed by checking its version:
You should see output similar to:
Last updated