I am new to nodejs and gulp stuff. I working on a nodejs project in which I have to run jslint on all the files. I am using gulp for this purpose.
My problem is that In order to run gulp on cli I don't want to install gulp globally and also does not want to update my path variable, So I have installed gulp and other node modules in my project locally using the package.json file
cd myproject
npm install
Since I don't want to install gulp globally and want to run the local gulp I have added script in my package.json file like this as given in this question
{
"name": "",
"version": "1.0.0",
"main": "index.js",
"private": true,
"dependencies": {
"async": "1.5.0"
},
"devDependencies": {
"gulp": "^3.9.0",
"gulp-jslint": "^0.2.2"
},
"scripts": {
"gulp": "./node_modules/.bin/gulp" // is this correct?
}
}
Add added a gulpfile.js inside my myproject folder
var gulp = require('gulp');
// include plug-ins
var jslint = require('gulp-jslint');
// JS hint task
gulp.task('lint', function() {
gulp.src('./common/srp/*.js')
.pipe(jslint())
.pipe(jslint.reporter('default'));
});
gulp.task("default", ["lint"]);
But now on my command line inside myproject folder, when I run gulp and gulp lint I get an error
user1-VirtualBox:~/myproject$ gulp lint
/usr/local/node-v0.10.26-linux-x64/bin/gulp No such file or directory
Its looking for gulp in the global node module.
Is there a way to make gulp run on cli without installing globally and updating PATH variable.
Any help will be appreciated Thanks
Scripts defined in
package.json
are accessed through NPM, i.e.npm run-script gulp
. I imagine you're trying to run plain oldgulp
, which should fail since you didn't install it globally.The scripts section won't automatically create an alias, which I think is your mistake here. You could define one yourself or create a simple bash script if you don't want to type it every time.
Like @snorberhuis said. The only way for me to get gulp to work globally was to call gulp manually I am building in a Jenkins environment
Execute Windows Batch Command
Execute Windows Batch Command
The way I did this after bashing my head every possible place is simply going to your Application and install npm dependencies like this:
1-
E:\webra-jenkins\Code\trunk\WebRa.Web>npm install
Once npm installed then go this directory
2-
[%Application_path%]\node_modules\.bin
And execute the gulp and give your file/task, like this:
3-
[%Application_path%]\node_modules\.bin>gulp gulpfile --tasks
In my case as I saw the following lines... I got the inner happiness
Now you can run your tasks 1 by one.
Try:
Example: