Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Node.js, PHP and APIs

asdf says 'No version is set for command npm'

ErrorNo version is set for command npm

Short answer

asdf runs a tool only when a .tool-versions file in the current folder, a parent folder or your home folder names its version. Run asdf current to see what asdf resolves, then set a Node.js version with asdf set and install it with asdf install if it is not yet on disk.

  • Applies to asdf 0.20, Node.js 22
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Ask asdf which version it resolves for Node.js, and from which file. An empty or missing line shows where the gap is.

    asdf current nodejs
    asdf list nodejs
  2. 2Match what you see, then jump to its fix

    1. 1asdf current nodejs shows no version, or no fileNo .tool-versions file covers this folderFix
    2. 2asdf current shows a version, but asdf list nodejs does not list itThe version is listed but not installedFix
    3. 3The repo has .nvmrc or .node-version, and no .tool-versionsThe project only has a .nvmrc or .node-version fileFix
    4. 4asdf current shows a version you did not set in any fileA shell variable overrides the file in this terminalFix

What does the error look like?

  • No version is set for command npm
  • No version is set for command node

Cause 1 of 4

No .tool-versions file covers this folder

1Check

asdf looks in the current folder first, then the parent folders, with the home folder file as the default. Without a listed version, running the tool errors.

asdf current nodejs
ls -a . ~ | grep tool-versions

2Fix

Set a version for this project, or in your home folder for a default across all projects.

asdf set nodejs 22.11.0
# or a default for every folder:
asdf set -u nodejs 22.11.0

3Verify

asdf current now names the version and the file.

asdf current nodejs
npm --version

Confirmed by asdf-vm.com

Did this fix it?

Cause 2 of 4

The version is listed but not installed

1Check

asdf enforces exact versions. A line in .tool-versions does not install anything by itself.

asdf current nodejs
asdf list nodejs

2Fix

Install the exact version named in the file, after adding the plugin if you have not.

asdf plugin add nodejs https://github.com/asdf-vm/asdf-nodejs.git
asdf install nodejs 22.11.0

3Verify

npm runs under the asdf version.

asdf list nodejs
npm --version

Confirmed by asdf-vm.com

Did this fix it?

Cause 3 of 4

The project only has a .nvmrc or .node-version file

1Check

asdf reads legacy version files only if you turn that on in your asdf configuration.

ls -a | grep -E "nvmrc|node-version|tool-versions"

2Fix

Either create a .tool-versions with asdf set, or enable legacy file support, so the nodejs plugin reads .nvmrc and .node-version.

# in ~/.asdfrc
legacy_version_file = yes

3Verify

asdf current nodejs reads the version from the legacy file.

asdf current nodejs

Confirmed by asdf-vm.com

Did this fix it?

Cause 4 of 4

A shell variable overrides the file in this terminal

1Check

ASDF_NODEJS_VERSION takes priority over .tool-versions in the current shell.

env | grep ASDF_

2Fix

Unset it, or set it to system to use the Node.js your operating system provides.

unset ASDF_NODEJS_VERSION

3Verify

asdf current nodejs follows the .tool-versions file again.

asdf current nodejs

Confirmed by asdf-vm.com

Did this fix it?

How do I stop it coming back?

  • Commit .tool-versions in every project, so a fresh clone knows the versions.
  • Install the exact version named in .tool-versions after pulling changes to it.
  • Set a default Node.js version in your home folder with asdf set -u.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Back end

ng serve says it cannot determine the project or target

Cannot determine project for command.

The Angular CLI looked through angular.json for a project that defines the target you asked for (serve, build, test) and found none, or found several and could not pick one.

3 causes, each with a fix

Back end

ng serve cannot find the dev-server builder package

Could not find the implementation for builder @angular/build:dev-server

The builder named in angular.json (for example @angular-devkit/build-angular:dev-server) is looked up as an npm package starting from the workspace root.

3 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.