88

I tried to install gulp by

npm install -g gulp

The output seems to be something like this. (i have skipped some logs)

npm http 304 https://registry.npmjs.org/string_decoder
npm http 304 https://registry.npmjs.org/lodash._htmlescapes
/usr/bin/gulp -> /usr/lib/node_modules/gulp/bin/gulp.js
gulp@3.6.2 /usr/lib/node_modules/gulp
├── tildify@0.2.0
├── pretty-hrtime@0.2.1
├── deprecated@0.0.1
├── archy@0.0.2
├── semver@2.2.1
├── chalk@0.4.0 (has-color@0.1.7, ansi-styles@1.0.0, strip-ansi@0.1.1)
├── orchestrator@0.3.3 (sequencify@0.0.7)
├── liftoff@0.9.8 (extend@1.2.1, minimist@0.0.8, resolve@0.6.3, findup-sync@0.1.3)
├── vinyl-fs@0.1.4 (graceful-fs@2.0.3, map-stream@0.1.0, mkdirp@0.3.5, vinyl@0.2.3, glob-stream@3.1.9, glob-watcher@0.0.6)
└── gulp-util@2.2.14 (lodash._reinterpolate@2.4.1, dateformat@1.0.7-1.2.3, minimist@0.0.8, vinyl@0.2.3, multipipe@0.0.2, through2@0.4.1, lodash.template@2.4.1)

In the above script i can see a line /usr/bin/gulp -> /usr/lib/node_modules/gulp/bin/gulp.js which i guess is making a simulink in bin folder. So i should be getting gulp globally but i get the this error.

No local gulp install found in /var/www/ksapp

Any idea why i am getting this error.

Thanks

harikrish
  • 2,009
  • 3
  • 19
  • 37

4 Answers4

104

As pointed out in the doc, you should install it globally (you did that) and add it to your project dev deps (locally):

npm install gulp --save-dev
Giacomo1968
  • 25,759
  • 11
  • 71
  • 103
Mangled Deutz
  • 11,384
  • 6
  • 39
  • 35
  • 1
    Is there a possibility for a Gulp not to copy node files into project local folder? Having Gulp installed globally, this command makes a local copy of it as I understand. – Vladislav Rastrusny Aug 18 '14 at 12:21
  • The point is that the local install guarantees that your project build will NOT break even if your system installs are upgraded (the global gulp install is just there to provide a binary command in the path). This is the same situation for grunt. – Mangled Deutz Feb 03 '15 at 00:04
  • 12
    I too hate full copies of node modules in each project folder, so I regularly use `npm link gulp --save-dev` – PA. Feb 13 '15 at 10:51
  • 1
    Nice, but I'm not seeing that `npm link gulp --save-dev` respects the `--save-dev` parameter. – Derek Greer Jun 08 '15 at 22:50
  • 2
    @PA, to again reiterate comments on the other answers, `npm link gulp` is a bad idea. – sfarbota Nov 28 '15 at 21:09
  • What is the point of installing globally if you then also have to install it locally?! With the number of little files that are bundled in the node_modules folder at over 2500 this is not a solution. – Peter Kionga-Kamau Mar 22 '19 at 02:28
  • The point was explained above (^^^ second comment). What is your concern with the number of files? – Mangled Deutz Apr 24 '19 at 16:01
35

I faced the same issue. Got it resolved by creating a link

npm link gulp
piscript
  • 419
  • 5
  • 8
  • 8
    Like stated in another comment, this is a bad idea. Build systems like gulp, or grunt, are designed in a way that a specific project can depend on a specific version of the build specific (thus, will still build no matter the state or installed versions of your global system). Trying to link together the global and local version of gulp is shooting yourself in the foot... – Mangled Deutz Mar 11 '15 at 18:26
  • @MangledDeutz I'm not interested in tying gulp to this specific project. I just want to use it as a little command line tool for automating some build tasks. My gulpfile won't be part of the git repo, and in fact, if I clone this repo on another computer, I might decide to not even use gulp to automate these tasks, I might use a different tool. I want to pretend node and npm don't exist, and gulp is just some little program in /usr/bin that looks for a gulpfile.js in the CWD and magically works. If that's all I want, is this answer not a reasonable thing to do? – Jack M Dec 26 '18 at 12:08
  • @JackM it's still not a reasonable thing, because depending on what version of gulp is installed system-wide, it may or may not work with that gulpfile.js (and "magically" breaks for no reason)... – Mangled Deutz Jan 29 '19 at 22:45
  • @MangledDeutz But that's true for any command line program that accepts a file as input. – Jack M Jan 29 '19 at 22:53
  • Yaaas! THIS! Let the developer decide when the global version is appropriate or not!! – Peter Kionga-Kamau Mar 22 '19 at 02:36
  • @JackM Which is why *every single application* that does rely on such a globally installed program (not being "vendored") ends-up breaking / bitroting. Which is why in the end someone had to come-up with Docker, which is basically doing the exact same thing you do not like here: vendor everything locally alongside the app... – Mangled Deutz Apr 24 '19 at 16:13
  • @VisionHive as a developer, it's your prerogative to change / rewrite an open-source application that you do not like ("gulp", here). Still, that doesn't mean the gulp authors should be compelled to adopt your ideas (especially if they are bad). – Mangled Deutz Apr 24 '19 at 16:17
  • To the point: when you develop a node app, you do vendor (aka "duplicate locally") your dependencies, because they change over time and you develp for a specific version of that. This is also true for your dev-dependencies. gulp is no different here: so, vendor it people. The global cli is just a convenience so you do not have to mess-up your PATH. NOT vendoring your build system is only practical with systems that ensure *very strong* backward compatibility over time. The javascript world is just not like that... – Mangled Deutz Apr 24 '19 at 16:28
  • @MangledDeutz Who said anything about dependencies? For my use case, gulp is no more a dependency of my project than my text editor is. It's a binary program I have installed on my computer which I happen to use while working. – Jack M Apr 25 '19 at 08:07
  • @JackM If the tool insist on doing something that you do not like, and you are not using the tool for what it's supposed to be used, then maybe you are using the wrong tool... Also, I honestly fail to see what problem exactly NOT installing gulp locally is solving (duplicated files? come on now :-))... Either way, not my circus, not my monkeys :-) - I don't even use gulp anymore personally (2019...) – Mangled Deutz Apr 27 '19 at 17:30
-2

Check /home/username/.npm directory: maybe groups/owner of files is root. Change to username:

chown -R username.username /home/username/.npm
István Pató
  • 351
  • 3
  • 7
-2

I've recently run into the "Local gulp not found" error message. I was able to work past it by creating a symlink from the global node_modules directory to the local project directory where my gulpfile.js is located.

  • 7
    You are then defeating the purpose of a locally available build system that does NOT break when you upgrade your base system. This is certainly a bad idea and goes counter to the authors intentions... – Mangled Deutz Feb 02 '15 at 20:21