npm install worked but the command is not found
zsh: command not found: eslintShort answer
npm puts a local install's command in the project's node_modules/.bin, which is not on your shell PATH, so run it with npx or from an npm script. A global install puts it in the prefix bin folder, which must be on your PATH. Check which kind of install you did.
Fix it fast
1Find out which cause you have
See whether the command was installed in this project or globally.
ls node_modules/.bin | head npm ls -g --depth=02Match what you see, then jump to its fix
- 1
The name appears in node_modules/.bin but not in the global listIt was installed locally, and local commands are not on PATHFix - 2
npm ls -g lists the package, yet the shell cannot find the commandIt was installed globally but the global bin folder is not on PATHFix - 3
node_modules/.bin has the command in another project folder, or none hereThe install was run in a different folder from the one you are in nowFix
- 1
What does the error look like?
zsh: command not found: eslintbash: vite: command not found'tsc' is not recognized as an internal or external command
Cause 1 of 3
It was installed locally, and local commands are not on PATH
1Check
A plain npm install links the command into ./node_modules/.bin of the project. npm scripts and npx see that folder, but your shell does not.
ls node_modules/.bin | grep eslint2Fix
Run it through npx, or add it to the scripts of package.json and call it with npm run.
npx eslint .
# or in package.json: "scripts": { "lint": "eslint ." }
npm run lint3Verify
The tool prints its output or version.
npx eslint --versionConfirmed by docs.npmjs.com
Cause 2 of 3
It was installed globally but the global bin folder is not on PATH
1Check
A global install links commands into the bin folder under the npm prefix on Unix. That folder must be listed in PATH.
npm config get prefix
echo "$PATH" | tr ':' '\n' | grep -n "$(npm config get prefix)"2Fix
Add the bin folder to PATH in the profile file your shell reads. zsh reads ~/.zshrc, and the change applies only to new shells.
echo 'export PATH="$(npm config get prefix)/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc3Verify
The shell finds the command.
command -v eslintConfirmed by docs.npmjs.com
Cause 3 of 3
The install was run in a different folder from the one you are in now
1Check
Local commands belong to one project. Moving to another folder, or running npm install above or below the project, leaves this folder without it.
pwd
ls package.json node_modules/.bin2Fix
Change to the folder that holds the project and run the command there, or install the package in this project.
cd path/to/your-project
npm install --save-dev eslint3Verify
npx finds the local copy.
npx eslint --versionConfirmed by docs.npmjs.com
How do I stop it coming back?
- Prefer local installs plus npm scripts; each project then carries its own tool version.
- Reserve global installs for tools you use outside any project.
- Check npm config get prefix after changing Node.js version managers.
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
npm install -g fails with EACCES on /usr/local/lib/node_modules
npm error syscall access
EACCES means npm tried to write global packages into a folder your user does not own, usually /usr/local/lib/node_modules.
2 causes, each with a fixBack end
The nest command is not found in the terminal
bash: nest: command not found
The shell cannot find a nest executable on its PATH.
3 causes, each with a fixBack end
node and npm vanish or are not found when nvm is installed
nvm current prints system in a new shell
nvm adds node and npm to PATH only for the version it has activated.
4 causes, each with a fixBack end
The serverless command is not found in the shell
bash: serverless: command not found
The shell can only run serverless if it is installed globally and the folder npm links global commands into is on PATH.
3 causes, each with a fixBack end
npm or a script fails in WSL with /usr/bin/env: 'bash\r'
/usr/bin/env: 'bash\r': No such file or directory
The \r in the message is a Windows line ending at the end of a script's first line, so Linux looks for a program called bash followed by a carriage return.
2 causes, each with a fixBack end
yarn command not found, or yarn global binaries not found
zsh: command not found: yarn
The shell cannot find the yarn binary or a tool installed with yarn global.
4 causes, each with a fix