Error: Cannot find module ‘laravel-elixir’ when use Gulp in Laravel PHP framework

Gulp is a javascript package which help us do tasks , for example run unit test, minify css etc., automatically.

I have been using Gulp and have found many errors, here is one of them.

module.js:328
throw err;
^
Error: Cannot find module ‘laravel-elixir’
at Function.Module._resolveFilename (module.js:326:15)
at Function.Module._load (module.js:277:25)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)

I found when I try to use Gulp for do a task for me in Laravel project , the cause is Gulp cannot find laravel-elxir (which is a test dependencies in Laravel).

Solution: I installed laravel-elxir inside the project by using npm.

npm install laravel-elixir --save-dev

It will take a little bit time to install. When finish installation , type ‘gulp’ in Terminal it must work.