0

gulpfile.js:

var gulp = require('gulp');                       
var console = require('console');                 

gulp.task('default', function() {                 
  console.log('The "Gulp Default Task" is done.');
}); 

nodejs commands:

λ gulp
[17:17:48] Local gulp not found in ~\nodework\dyncss
[17:17:48] Try running: npm install gulp

$ (master) (dyncss@0.0.0)
λ npm install gulp --save-dev
C:\Users\TheStaabFamily\AppData\Roaming\npm\gulp -> C:\Users\TheStaabFamily\AppData\Roaming\npm\node_modules\gulp\bin\gulp.js
C:\Users\TheStaabFamily\AppData\Roaming\npm
└── gulp@3.9.0

$ (master) (dyncss@0.0.0)
λ gulp
[20:23:58] Local gulp not found in ~\nodework\dyncss
[20:23:59] Try running: npm install gulp

WTF? This is on Win7 x64. It took me quite awhile to install VStudio so node-gyp (a dependency of gulp) could build itself during the gulp install. I initially installed gulp with:

npm install -g gulp

Incidentally, my package.json is also not being updated by npm when I try to install gulp with the -D or --save-dev options. I am a new node user so please excuse if this question is too noobie. THANKS!!!

Sanford Staab
  • 239
  • 2
  • 10
  • Version Info:λ node --version v4.2.2 $ (master) (dyncss@0.0.0) λ npm --version 3.5.2 – Sanford Staab Dec 10 '15 at 04:43
  • Local installs shouldn't be installed under `AppData\Roaming`. Are you running the `install` command while in that directory? Or, under `~\nodework\dyncss`? What do `npm prefix` and `npm root` give you? – Jonathan Lonowski Dec 10 '15 at 05:11
  • try running `npm install -g gulp` & trying it again. – Nick Snick Dec 10 '15 at 10:47
  • I was running in dyncss which is my new project that I want to use gulp for so I am marking it as a devDependency in my dyncss package.json file. As I said, my first gulp install attempt was globally and it failed with the above error telling me it was not found LOCALLY. – Sanford Staab Dec 11 '15 at 06:59

2 Answers2

1

See http://www.bartread.com/2014/02/17/whats-difference-locally-globally-installing-npm-packages/ for details.

Gulp should be installed globally and then linked into projects that use it:

npm install -g gulp

npm link --local gulp (run from your project root directory)

or...

Installed locally and linked globally:

npm install gulp
npm link --global gulp
Sanford Staab
  • 239
  • 2
  • 10
0

While installing gulp don't forget to put '-g' in command. it will install globally.

i hope because of user rights and all, sometimes during installation gulp install path was not added in environment PATH variable. you must have to add manually your installed directory path in PATH variable. so that 'gulp' keyword will be available locally globally.

Shrinath
  • 364
  • 1
  • 13
  • I have seen in several answers things about "you must install globally" or "try installing locally". I am seeing another problem that could be related - the inability to find AppData\Roaming\npm\package.json which happens whenever I try a npm prune operation. I completely removed npm using http://stackoverflow.com/questions/20711240/how-to-completely-remove-node-js-from-windows and reinstalled, did a reinstall of nodejs (using chocolatey this time) and npm installed gulp and other devDependencies for my tiny first module project and hit this again. – Sanford Staab Dec 11 '15 at 06:44
  • A good article on the global vs local install issue is here: http://www.bartread.com/2014/02/17/whats-difference-locally-globally-installing-npm-packages/ in there it says: Global packages are for anything that you need to access from the shell. By contrast local packages are for using within your apps. which tells me why I should install gulp globally - which tells me why its not in my path. – Sanford Staab Dec 11 '15 at 06:46
  • Seems to me npm should have a way for a package to force itself to only be installed globally so users don't trip over this for those shell-accessed kinds of packages. Since I am new to nodejs/npm, maybe someone, if they agree with this idea, could put in a feature request for this. – Sanford Staab Dec 11 '15 at 06:55
  • Ah, the article on global vs local sited in my second comment above gave me the answer. Gulp is a package you want to install globally and then LINK into any projects that use it. This effectively installs the package both globally and locally. The feature I propose to npm should allow a package to state its prefered installation locale: global only, local only, both, or don't care. The shell should then warn or prompt users that try to install the package differently than its preferences.to help avoid this whole problem. – Sanford Staab Dec 11 '15 at 07:05
  • @SanfordStaab i hope you got the solution. – Shrinath Dec 11 '15 at 10:02