Search code examples
laravellaravel-5gulpnode-moduleslaravel-elixir

TypeError: require.extensions.hasOwnProperty is not a function - on running gulp


I was trying to run gulp inside my project directory. I have gone through so many articles. Also try running most of given commands (as solutions) in cmd. But the same problem occurs.

if (!require.extensions.hasOwnProperty(ext)) {
                         ^
TypeError: require.extensions.hasOwnProperty is not a function

This is how my package.json looks like.

{
  "private": true,
  "devDependencies": {
    "gulp": "^3.9.1",
    "laravel-elixir": "^2.3.13"
  },
  "dependencies": {
    "bower": "^1.5.2",
    "require-dir": "^1.2.0"
  }
}

It would be great if anyone can help me to solve this.


Solution

  • Finally found an answer. I just changed the below code line in <project>/node_modules/laravel-elixir/node_modules/require-dir/index.js file.

    if (!require.extensions.hasOwnProperty(ext)) {
    

    as:

    if (!Object.prototype.hasOwnProperty.call(require.extensions, ext)) {
    

    And it finally works now.