93

I created a module (webapp-module-storage) which has the following definitions:

package.json

{
  "dependencies": {
    ...
  },
  "devDependencies": {
    "gulp": "^3.9.1",
    ...
  },
  "name": "webapp-module-storage",
  "scripts": {
    "postinstall": "gulp build",
    "test": "gulp test"
  }
}

I thought I can use my module inside another module when installing it with:

  • npm install github:myorg/webapp-module-storage#master

However, when I install my module, I am getting this error:

Local gulp not found

Try running: npm install gulp

Screenshot

enter image description here

My understanding is, that gulp is shipped together with my module because I declared it in devDependencies but it looks like that my npm postinstall script cannot find gulp.

Am I missing something?

Benny Code
  • 51,456
  • 28
  • 233
  • 198
  • Possible duplicate of [What's the difference between dependencies, devDependencies and peerDependencies in npm package.json file?](http://stackoverflow.com/questions/18875674/whats-the-difference-between-dependencies-devdependencies-and-peerdependencies) – Sven Schoenung Jun 29 '16 at 20:24
  • 1
    Perform `npm i gulp -D` in folder project. Note: gulp4 can cause issues in old projects, for install a specific version use like this: `npm i gulp@3.9.1 -D` (ps `-D` for devDependencies) – Protomen Mar 27 '19 at 03:12

7 Answers7

198

Try running npm link gulp in your application directory (to create a local link to the globally installed Gulp module).

Fab Fuerste
  • 2,211
  • 1
  • 8
  • 17
  • 1
    Laravel / homestead user here. The above command didn't work for me, however `npm link gulp --no-bin-links` worked. – Lpgfmk Sep 14 '17 at 14:50
  • 7
    To clarify, `npm link [module]` creates a symlink from [module]'s global install folder to ./node_modules/[module] at the current path (`npm link` w/o name links packages, see [man page](https://github.com/npm/npm/blob/d46015256941ddfff1463338e3e2f8f77624a1ff/doc/cli/npm-link.md)) – techturbulence Oct 11 '17 at 09:43
23

Try installing your dependencies first:

npm install

If still does not work, install gulp globally:

npm install -g gulp

if you find problems installing it. type sudo before npm.

In case you need more info about why you need gulp globally and locally read this answer

Community
  • 1
  • 1
Sebastian S
  • 807
  • 6
  • 15
16

I have tried all the solutions mentioned. At the end I was able to solve the problem by realising that the gulpfile.js file was missing on the location i was using the gulp. After placing the gulpfile.js in the folder from where I was executing gulp, it worked for me.

  • I made the same mistake. I was one directory up from where I was suppose to be. This can easily happen if you are going full speed with setting up something like an Express Generator environment where you have multiple sub apps under a root location. I just needed to slow down. – klewis Jun 09 '21 at 14:39
3

npm link gulp --no-bin-links
Run this

where npm link gulp creates a local link to globally installed gulp module and --no-bin-links argument will prevent npm from creating symlinks for any binaries the package might contain.

You can't translate symlinks to a synchronized folder on Windows share, so you will need '--no-bin-links' to go around it.

Use it for any filesystem that doesn’t support symbolic links.

Symlinks, or symbolic links, are “virtual” files or folders which reference a physical file or folder located elsewhere, and are an important feature built in to many operating systems, including Linux and Windows.

Parikshit Singh
  • 167
  • 3
  • 4
  • 1
    Hello! While this code may solve the question, [including an explanation](https://meta.stackexchange.com/q/114762) of how and why this solves the problem would really help to improve the quality of your post, and probably result in more up-votes. Remember that you are answering the question for readers in the future, not just the person asking now. Please [edit] your answer to add explanations and give an indication of what limitations and assumptions apply. – Brian61354270 Jun 21 '20 at 21:52
  • Thank you @Brain for pointing out :). I have edited it. – Parikshit Singh Jun 21 '20 at 22:43
1

npm link gulp --force

Using this command worked well for me.

David Buck
  • 3,752
  • 35
  • 31
  • 35
0

Put Gulp into the regular dependencies of the project:

npm i gulp

And then have your scripts section reference the local Gulp like that:

  "scripts": {
    "postinstall": "./node_modules/.bin/gulp build",
    "test": "./node_modules/.bin/gulp test"
  }
leymannx
  • 5,138
  • 5
  • 45
  • 48
0

I used Visual Studio Code and Terminal with Power Shell and have this problem either. This problem for me disappeared when I changed Execution Policy. I get info about this solution from gulp. Execution Policy changin example is in the picture.Set Execution Policy

Sharunas Bielskis
  • 1,033
  • 1
  • 16
  • 25