Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running Gulp throws error "Cannot find module './lib/_stream_writable.js'"

I am building a theme over Root's Sage WordPress Theme. After setting up and running the necessary commands. Whenever I run Gulp it throws the following error

module.js: 338
throw err; ^
Error: Cannot find module './lib/_stream_writable.js'
at Function.Module._resolveFilename(module.js: 336: 15)
at Function.Module._load(module.js: 278: 25)
at Module.require(module.js: 365: 17)
at require(module.js: 384: 17)
at Object. < anonymous > (/var/www/website/wp-content/themes/example/node_modules/gulp-autoprefixer/node_modules/gulp-util/node_modules/multipipe/node_modules/duplexer2/node_modules/readable-stream/readable.js: 4: 20)
at Module._compile(module.js: 460: 26)
at Object.Module._extensions..js(module.js: 478: 10)
at Module.load(module.js: 355: 32)
at Function.Module._load(module.js: 310: 12)
at Module.require(module.js: 365: 17)
at require(module.js: 384: 17)

I tried re-installing the readable-stream module, but still get the same. Any help is appreciated.

Thanks.

like image 745
tank Avatar asked May 21 '15 09:05

tank


2 Answers

There are several things that can go wrong here depending on your project, dependencies, and file structure. I've had this many times, and its always just a slight tweak, a small error. But assuming its all fairly basic, you want to:

A: Make sure the that gulp is being 'required' at the start of your gulpfile, before anything else.

B: Node_modules... should not need to be deleted and later re-installed in order to work.

C: Make sure you are running the appropriate/ current version of Node

D: Make sure you are piping properly. If a destination is wrong when needed, it breaks. If a destination / Dist is present when it is not needed, it breaks

E: Make sure you have done

npm install 
npm install gulp -g
npm install gulp --save-dev

F: Run gulp from the root and make sure the watcher is set up properly

Hopefully it helps, or at least leads to a better error.

like image 134
Vontei Avatar answered Nov 07 '22 20:11

Vontei


You could try deleting node_modules and reinstalling using administrator privileges (ie., sudo npm install on Linux/Mac or running the command window as Administrator on Windows). This is what has solved similar issues for me in the past.

like image 2
kmaida Avatar answered Nov 07 '22 21:11

kmaida