gulp says Local gulp not found and asks you to run npm install gulp
Local gulp not found in <project path>Short answer
gulp-cli is only a launcher. It looks for a copy of gulp inside the current project and stops with exit code 1 if there is none. Run npm install in the project to restore node_modules, or add gulp as a dev dependency, and start gulp from the folder that holds package.json.
Fix it fast
1Find out which cause you have
Check where you are and what is installed there. The launcher looks in the current folder.
pwd ls package.json node_modules/gulp gulp --version2Match what you see, then jump to its fix
- 1
Local modules not found in ... Try running: npm installnode_modules is missing (fresh clone or deleted folder)Fix - 2
Local gulp not found in ... Try running: npm install gulpgulp is not a dependency of this projectFix - 3
The message names a folder that is not your project root.You run gulp from a different folder than the projectFix
- 1
What does the error look like?
Local gulp not found in <project path>Try running: npm install gulpLocal modules not found in <project path>Try running: npm install
Cause 1 of 3
node_modules is missing (fresh clone or deleted folder)
1Check
gulp-cli checks whether package.json exists but node_modules does not. In that case it suggests the full install, and it suggests yarn if a yarn.lock is present.
ls package.json node_modules2Fix
Install everything the project lists.
npm install
# a project with yarn.lock:
yarn install3Verify
gulp reports both versions.
gulp --versionConfirmed by raw.githubusercontent.com
Cause 2 of 3
gulp is not a dependency of this project
1Check
node_modules exists but contains no gulp. The gulp quick start installs the command-line tool globally and gulp itself locally as a dev dependency; installing only the tool leaves the project without gulp.
npm ls gulp
npm ls --global gulp-cli2Fix
Install gulp into the project, and the command-line tool globally if you want the plain gulp command.
npm install --save-dev gulp
npm install --global gulp-cli3Verify
The version command shows a CLI version and a local version.
gulp --versionConfirmed by gulpjs.com
Cause 3 of 3
You run gulp from a different folder than the project
1Check
gulp-cli searches for gulp from its working directory. Running it in a parent or an unrelated folder finds nothing.
pwd2Fix
Change into the project root, or point gulp at it with --cwd.
cd /path/to/project && gulp
# or
gulp --cwd /path/to/project3Verify
gulp reports the CLI and local versions.
gulp --versionConfirmed by github.com
How do I stop it coming back?
- Keep gulp in devDependencies so npm install always brings it back.
- Run gulp through an npm script in CI so the working folder is always the project root.
- Commit the lockfile so every machine installs the same gulp.
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