I had previously installed gulp globally using npm install gulp -g
. Then I cloned an existing project, and that required me to use its own gulp. Now when I do a gulp -v
from outside my project folder, I get a mismatch like this.
C:\Users\userme> [11:14:05] CLI version 3.8.11 [11:14:05] Local version 1.0.0
And when I do a gulp from my project folder, I get this.
C:\project\new\tools> [11:14:26] CLI version 3.8.11 [11:14:26] Local version 3.8.11
Now I have not been able to merge my JS files properly using gulp (I'm getting some weird formatting errors in the min file) and I suspect it has something to do with this mismatch.
Note - I did try updating the global gulp by using npm update [email protected] -g
but nothing happened. i still get the mismatch.
Update to describe the issue: I am using gulp to merge multiple JS files into 1 single main.js file. The formatting that I get in the merged file has a syntactical error in it.
Expected output in merged file -
... define('utils/knockoutBindings/slider',['require','ko','jquery'],function(require) { 'use strict'; var ko = require('ko'); var $ = require('jquery'); ...
Actual output in merged file (this 1 line of code below is wrongly replacing the entire 4 lines above) -
... var'utils/knockoutBindings/slider',['require','ko','jquery'],function(require) { ...
It might seem that there is an issue in the gulp code, but the same code is used by other users and it works well on their end. The only difference we have found is in the mismatch in my gulp versions.
BUT if you don't have admin rights and you can update the local version, but not the global version, then you can run node ./node_modules/gulp/bin/gulp. js from your project folder and it will execute the gulp file, even if you have the wrong CLI version, but you need to have the default task set up.
With gulp-cli globally installed : CLI version 1.2.1 Local version 4.0.0-alpha.2. In this case the version displayed is the global version of gulp-cli and the local version of gulp. The global gulp 3.9.
To install Gulp locally, navigate to your project directory and run npm install gulp . You can save it to your package. json dependencies by running npm install gulp --save-dev . Once you have Gulp installed locally, you can then proceed to create your gulpfile.
x is the current released npm package that works fine with Node 8 - LTS(Long Term Support stable, which is supported till 2019). When you perform npm install --save-dev gulp , by default it will fetch and install gulp 3.9.
I am answering my own question, just so it is useful for others.
- Is there a way to remove the global gulp version, but keep the project specific gulp?
No. AFAIK, you are required to install gulp globally as well as one specific to your project.
More info on gulp versions here.
- Or can I update my global version gulp to @3.8.11?
Since I was facing a mismatch in my local version, I had to update it from the project folder itself.
npm install [email protected] --save
More info on this here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With