As shown in the screen shot below I am not able to run gulp
to concat the JavaScript files. Its saying that gulp is not defined
.
I have tried the following commands:
npm install -g gulp
npm install gulp
npm install gulp --save-dev
I have also set the environment variables as following:
C:\Users\<user>\AppData\Roaming\npm;C:\Python27;C:\Users\<user>\AppData\Roaming\npm\node_modules;C:\Users\<user>\AppData\Roaming\npm\node_modules\gulp;
var concat = require('gulp-concat');
var rename = require('gulp-rename');
var uglify = require('gulp-uglify');
//script paths
var jsFiles = 'scripts/*.js',
jsDest = 'dist/scripts';
gulp.task('scripts', function() {
return gulp.src(jsFiles)
.pipe(concat('scripts.js'))
.pipe(gulp.dest(jsDest));
});
Its occurs on Windows and usually one of the following fixes it:
Normally, It isn't a problem on Windows, but it could be a issue with the PATH. The package will try to get the PATH from the environment, but you can override it by adding exec_args to your gulp settings. For example, on Ubuntu:
"exec_args": { "path": "/bin:/usr/bin:/usr/local/bin" }
Hope It will be OK.
Source: https://github.com/NicoSantangelo/sublime-gulp/issues/12
you just need to install and require
gulp
locally, you probably only installed it globallyAt the command line
In your gulpfile.js
this is a different dependency than the command line dependency (that you installed globally). More specifically, it is the same NPM package, but the command line program will execute code usually from a different entry point in the NPM package then what require('X') will return.
If we go to the package.json file in the Gulp project on Github, it will tell the whole story:
so at the command line:
will execute this:
on the other hand, require('gulp') in your code will return the value of this:
normally we see this in a package.json file as:
but since this is the default, they just omitted it (which is dumb IMO, better to be explicit, but they aren't the first project I have seen take the lame shorthand route.).