Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uninstalling Gulp globally (but not locally)

Tags:

gulp

New to Gulp, somehow I installed different versions of Gulp globally and locally, triggering version mismatch warning messages. Is it possible for me to uninstall Gulp globally without affecting local installs?

like image 699
drake035 Avatar asked May 16 '16 08:05

drake035


People also ask

Does gulp need to be installed globally?

By installing it globally the gulp script gets into your PATH because the global node/bin/ directory is most likely on your path. To respect your local dependencies though, gulp will use your locally installed version of itself to run the gulpfile.

How does installing gulp globally?

To install the Gulp CLI globally, on your command line, run npm install gulp-cli -g . The -g flag means npm will install the package in the global npm directory, so you can run the gulp command from any directory.

How do I know if gulp is installed?

First run npm -g install gulp-cli then run gulp -v. Alternatively, you can just run npm list gulp.


1 Answers

Yes you can.

You can uninstall using the -g flag, it will make sure only the global package is removed:

npm uninstall -g gulp 

To remove a local package and remove it from the package.json dependencies property use:

npm uninstall package-name

To remove a local package and remove it from the package.json devDependencies property use:

npm uninstall -D package-name

Update: As you may have noticed, running "gulp" in your terminal now produces an error saying "No such file or directory"

You can just call the gulp executable directly. e.g:

./node_modules/.bin/gulp [arguments...]

Update: npm 5.2.0 and above comes with a new tool called 'npx'

Using the below command will look for the gulp binary for you:

npx gulp

Read more about npx in this Medium post.

like image 74
elad.chen Avatar answered Oct 12 '22 19:10

elad.chen