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

StreetGT's avatar

Gulp / Elixir .src/init

Hello there, I'm having a problem running gulp. Using Node v6 Here is the log.

my package.json

{
  "private": true,
  "scripts": {
    "prod": "gulp --production",
    "dev": "gulp watch"
  },
  "devDependencies": {
    "gulp": "^3.9.1",
    "laravel-elixir": "^6.0.0-9",
    "bootstrap-sass": "^3.3.7",
    "jquery": "^3.1.0"
  }
}
> $ gulp
[21:48:26] Using gulpfile ~/Code/gtanetwork-banners/gulpfile.js
[21:48:26] Starting 'all'...
[21:48:26] Starting 'sass'...
[21:48:26] 'sass' errored after 12 ms
[21:48:26] Error: Cannot find module './src/init'
    at Function.Module._resolveFilename (module.js:440:15)
    at Function.Module._load (module.js:388:25)
    at Module.require (module.js:468:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/tiagocardoso/Code/gtanetwork-banners/node_modules/gulp-sourcemaps/index.js:4:9)
    at Module._compile (module.js:541:32)
    at Object.Module._extensions..js (module.js:550:10)
    at Module.load (module.js:458:32)
    at tryModuleLoad (module.js:417:12)
    at Function.Module._load (module.js:409:3)
[21:48:26] 'all' errored after 15 ms
[21:48:26] Error in plugin 'run-sequence(sass)'
Message:
    Cannot find module './src/init'
Details:
    code: MODULE_NOT_FOUND
Stack:
Error: Cannot find module './src/init'
    at Function.Module._resolveFilename (module.js:440:15)
    at Function.Module._load (module.js:388:25)
    at Module.require (module.js:468:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/tiagocardoso/Code/gtanetwork-banners/node_modules/gulp-sourcemaps/index.js:4:9)
    at Module._compile (module.js:541:32)
    at Object.Module._extensions..js (module.js:550:10)
    at Module.load (module.js:458:32)
    at tryModuleLoad (module.js:417:12)
    at Function.Module._load (module.js:409:3)
0 likes
21 replies
martinbean's avatar

@StreetGT I’ve started getting the exact save error this evening on a fresh install.

3 likes
martinbean's avatar

Looking at the stack trace and in node_modules/gulp-sourcemaps/index.js, it seems to be trying to require ./src/init which doesn’t exist in the directory, but does in the GitHub repository: https://github.com/floridoo/gulp-sourcemaps/blob/master/src/init.js

I know paths can be ignored in an .npmignore file but can’t see one in the repository. So is the src/ directory being excluding in npm installs some other way?

2 likes
shealan's avatar

Haha so glad it isn't just me. Mine is screwed as well.

I have a feeling we have a leftpad situation again....

willvincent's avatar

src has never been part of the repo for releases (look at the tags on github, rather than the default branches):

tags

index.js in the release is the compiled version of what's in src in the main repo branches... specifically which version is being troublesome?

christopher's avatar

Glad i am not the only one .. I am having the same Issue.

CharlesW's avatar

@alansslva wrote: I copied the files manually, and it worked

Sorry to trouble you, but can you be very explicit about what you put where?

suditugeorge94's avatar

@alansslva what files did you copy and where I am facing the same problem.I am sorry I am using the first time Laravel.

mattystowe's avatar

Fixed by adding lock to dependencies in package.json file.

"gulp-sourcemaps": "2.0.0",

remove npm_modules and then npm install again afresh

My package.json file below for example.

{ "private": true, "scripts": { "prod": "gulp --production", "dev": "gulp watch" }, "devDependencies": { "gulp": "^3.9.1", "gulp-sourcemaps": "2.0.0", "laravel-elixir": "^5.0.0", "bootstrap-sass": "^3.3.0", "alt": "^0.17.9", "angular": "^1.5.3", "angular-animate": "^1.5.3", "angular-loading-bar": "^0.9.0", "angular-sanitize": "^1.5.3", "angular-ui-router": "^0.2.15", "filepicker-js": "^2.4.5", "jquery": "^2.1.4", "lodash": "^4.11.2", "ng-tags-input": "^3.0.0", "satellizer": "^0.14.0", "uuid": "^2.0.2", "vinyl-source-stream": "^1.1.0" }, "dependencies": { "angular-chart.js": "^1.0.2", "gulp-sourcemaps": "2.0.0", "ng-sortable": "^1.3.6", "sweetalert": "^1.1.3", "toastr": "^2.1.2" } }

mattystowe's avatar

@JakeYeager i'm looking at npm shrinkwrap to try and lock the npm packages down - like in the composer.lock file. Never used it before - but after this incident wasted 3 hours of my life I thought I'd dive in....

shealan's avatar

Seems to be fixed now. Removed my node_modules folder and re-ran sudo npm install and it works again.

2 likes
Nicholaus's avatar

In addition to removing my node_modules folder, I also removed the .npm folder (off your home directory), then ran npm install again. Now gulp is working again.

Starting to question how much I really want to rely on frameworks that are heavily dependent on dependencies...

CharlesW's avatar

@christopher wrote: Copy the Folder src to your node_modules/gulp-sourcemaps Folder. This should do the trick.

That worked great, thank you!

willvincent's avatar

@Nicholaus valid concern -- but this is very much a node issue. node packages are notorious for just stopping working at some point. the entire node ecosystem is very "wild west"

And -- it's not like you have to use gulp to use laravel...

DoitOnlineMedia's avatar

Had the same issue, first thought it was Yarn. I just removed the folder: '/node_modules/laravel-elixir/gulp-sourcemaps' for the time being.

Mapping them still works.

Evert.Ramos's avatar

To fix that you got to:

node_modules/laravel-elixir/packages.json

and change the gulp-sourcemaps version to be locked at: "1.7", so it will be:

            "gulp-sourcemaps": "1.7.*",

Please or to participate in this conversation.