Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Marwelln's avatar

Cannot find module '.\vendor\laravel\elixir\Elixir'

I have a fresh install of laravel/laravel, installed with composer create-project laravel/laravel . dev-develop. I then ran npm install – everything went fine, but when I try to run gulp after that I get Cannot find module '.\vendor\laravel\elixir\Elixir'. How come?

H:\Binary\nginx\foobar.com>gulp

module.js:340
    throw err;
          ^
Error: Cannot find module '.\vendor\laravel\elixir\Elixir'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (H:\Binary\nginx\foobar.com\Gulpfile.js:1:76)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)

laravel/elixir have been installed by Composer.

I am running Windows.

0 likes
30 replies
BenSmith's avatar

A recent commit to elixir now has:


var elixir = require('laravel-elixir');

as the way to require elixir. That being said, I did a composer update and made the change above and now rather than the error you were getting, I'm getting:


module.js:340
throw err;
^
Error: Cannot find module 'laravel-elixir'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (pathtofile/Gulpfile.js:1:76)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)

Marwelln's avatar
Marwelln
OP
Best Answer
Level 4

So I guess the composer package laravel/elixir won't be used anymore.

I solved this by changing the first line in Gulpfile.js to var elixir = require('laravel-elixir');, I then updated packages.json with "laravel-elixir": "*",, I then ran npm install again. After that I could run gulp without problem.

25 likes
JeffreyWay's avatar

Yeah, we're switching Elixir over to NPM. You'll probably see an update to the laravel/laravel repo today.

Punslinger's avatar

I install a fresh laravel 5.0 version. - go into the folder - npm install gulp - npm install - Change the gulpfile.js to match the video. - elixir(function(mix) { mix.less("bootstrap.less") .routes() .events() .phpUnit(); }); - Add the less/boostrap.less file in the resources/assets/less folder.

  • Run gulp and get this. Why do the events throw an error? Is this the turmoil of the transitional patch or have i done something grievous?

/Applications/MAMP/htdocs/internal_projects/Gulpfile.js:17 .events() ^ TypeError: Cannot call method 'events' of undefined at /Applications/MAMP/htdocs/internal_projects/Gulpfile.js:17:9 at Elixir (/Applications/MAMP/htdocs/internal_projects/node_modules/laravel-elixir/index.js:3:2) at Object. (/Applications/MAMP/htdocs/internal_projects/Gulpfile.js:14:1) at Module._compile (module.js:456:26) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Module.require (module.js:364:17) at require (module.js:380:17) at Liftoff.handleArguments (/usr/local/lib/node_modules/gulp/bin/gulp.js:108:3)

JeffreyWay's avatar

What does your Gulpfile look like? Is it similar to:

var elixir = require('laravel-elixir');

elixir(function(mix) {
    mix.events().routes();
});

1 like
nfauchelle's avatar

I had routes() before events(). after changing the order of events() before routes() the issue was resolved. This was using the Gulpfile laravel installed 16~ hours ago.

nfauchelle's avatar

It seems the issue is to do with the return of routes(). Because if I do routes().phpUnit() then I get an error that "TypeError: Object #Object has no method 'phpunit'" but if it goes before the routes then it seems to work.

JeffreyWay's avatar

Yeah, looks like I forgot to return the config object in that particular task. All fixed. Do npm install to pull in the update, and you should be good to go.

3 likes
psgganesh's avatar

Thanks @andyroo2000, just an npm install followed by gulp, worked fine ... Instead of .publish, used .copy, just in case if someone stumbles upon this issue....

1 like
rampegg's avatar

I also had this problem on linux mint, resolved by 'sudo apt-get install g++'

Rahul's avatar

Somebody please help me with this error, i tried to solve it a lot of time but at the very last i'm here , this is error

npm ERR! Linux 3.19.0-25-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install"
npm ERR! node v5.3.0
npm ERR! npm  v3.3.12
npm ERR! path ../acorn/bin/acorn
npm ERR! code EPROTO
npm ERR! errno -71
npm ERR! syscall symlink

npm ERR! EPROTO: protocol error, symlink '../acorn/bin/acorn' -> '/home/vagrant/sites/l5/node_modules/.bin/acorn'
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>
npm ERR! Linux 3.19.0-25-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install"
npm ERR! node v5.3.0
npm ERR! npm  v3.3.12
npm ERR! path npm-debug.log.719e6356b1a6cd7da2aaaf0f06e35bb0
npm ERR! code ETXTBSY
npm ERR! errno -26
npm ERR! syscall rename

npm ERR! ETXTBSY: text file is busy, rename 'npm-debug.log.719e6356b1a6cd7da2aaaf0f06e35bb0' -> 'npm-debug.log'
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:
npm ERR!     /home/vagrant/sites/l5/npm-debug.log
vagrant@homestead:~/sites/l5$ gulp
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)
    at Object.<anonymous> (/home/vagrant/sites/l5/gulpfile.js:1:76)
    at Module._compile (module.js:398:26)
    at Object.Module._extensions..js (module.js:405:10)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Module.require (module.js:354:17)
    at require (internal/module.js:12:17)

my package.json files is :-

{
  "private": true,
  "devDependencies": {
    "gulp": "^3.8.8"
  },
  "dependencies": {
    "laravel-elixir": "*",
    "bootstrap-sass": "^3.0.0"
  }
}

my gulpfile.js :-

var elixir = require('laravel-elixir');

elixir(function(mix) {
   mix.sass('app.scss');
});

I'm using laravel 5.2 using it's brand new homestead 0.4.0 with php7.. please help me to resolve this issue.

pavelpage's avatar

Well, for this moment I found only one solution: reinstall of nodejs.

BrianDillingham's avatar

@pavelpage I finally got it to work by installing npm on my computer vs using homestead and upgrading the dependency to laravel-elixir 5.0 in the package.json file

zschuessler's avatar

Looking into the output it was related to the g++ and node-gyp packages for me. Everything was fixed following the suggestion by @rampegg - simply install the g++ package:

$sudo apt-get install g++

In addition, I had to clear my npm cache:

$ npm cache clear --force

Last but not least, delete the npm-lock.json file.

Now delete the node_modules folder and run npm install as normal.

Please or to participate in this conversation.