asdf says 'No version is set for command npm'
No version is set for command npmShort 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.
Fix it fast
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 nodejs2Match what you see, then jump to its fix
- 1
asdf current nodejs shows no version, or no fileNo .tool-versions file covers this folderFix - 2
asdf current shows a version, but asdf list nodejs does not list itThe version is listed but not installedFix - 3
The repo has .nvmrc or .node-version, and no .tool-versionsThe project only has a .nvmrc or .node-version fileFix - 4
asdf current shows a version you did not set in any fileA shell variable overrides the file in this terminalFix
- 1
What does the error look like?
No version is set for command npmNo 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-versions2Fix
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.03Verify
asdf current now names the version and the file.
asdf current nodejs
npm --versionConfirmed by asdf-vm.com
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 nodejs2Fix
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.03Verify
npm runs under the asdf version.
asdf list nodejs
npm --versionConfirmed by asdf-vm.com
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 = yes3Verify
asdf current nodejs reads the version from the legacy file.
asdf current nodejsConfirmed by asdf-vm.com
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_VERSION3Verify
asdf current nodejs follows the .tool-versions file again.
asdf current nodejsConfirmed by asdf-vm.com
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 fixBack end
ng fails with Cannot find module @angular/cli/bin/ng
Cannot find module '@angular/cli/bin/ng'
The ng command is the entry point to the Angular CLI package.
2 causes, each with a fixBack end
Angular app shows 'Cannot GET /' when served by a Node.js server
Cannot GET /dashboard
Cannot GET / is Express saying no route or file matches the request.
3 causes, each with a fixBack 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 fixBack end
Angular build says it cannot resolve '@angular/localize/init'
Can't resolve '@angular/localize/init' in '/usr/src/app/src'
The build imports @angular/localize, and that package is not in node_modules.
2 causes, each with a fixBack end
The command npm run build -- --prod exited with code 1 (Angular)
The command "npm run build -- --prod" exited with code 1
Exit code 1 only says the build failed; the real message is above it.
2 causes, each with a fix