Search code examples
javascriptnode.jserror-handlinggulpwrench

Error: Cannot find module 'wrench', I'm getting this error, when i run gulp command


I have installed npm ,bower and gulp in both local and globally.Still i'm getting this error when i run gulp in that folder.

Error: Cannot find module 'wrench'  
at Function.Module._resolveFilename (module.js:325:15)  
at Function.Module._load (module.js:276:25)  
at Module.require (module.js:353:17)  
at require (internal/module.js:12:17)  
at Object.<anonymous> (/home/myPC/documents/workspace/frontend/gulpfile.js:10:14)  
at Module._compile (module.js:409:26)  
at Object.Module._extensions..js (module.js:416:10)  
at Module.load (module.js:343:32)  
at Function.Module._load (module.js:300:12)  
at Module.require (module.js:353:17)  
at require (internal/module.js:12:17)  

Here is my gulpfile.js

'use strict';  

var gulp = require('gulp');  
var wrench = require('wrench');  


wrench.readdirSyncRecursive('./gulp').filter(function (file)  
{
    return (/\.(js|coffee)$/i).test(file);  
}).map(function (file)  
{
    require('./gulp/' + file);  
});  


gulp.task('default', ['clean'], function ()  
{  
    gulp.start('build');  
});

Here is my package.json

{  
"name": "admin",  
"version": "1.2.2",  
"dependencies":  
{},  
"scripts":  
{  
    "test": "gulp test"  
},  
"devDependencies":  
{  
    "browser-sync": "~2.9.11",  
    "browser-sync-spa": "~1.0.3",  
    "chalk": "~1.1.1",  
    "del": "~2.0.2",  
    "eslint-plugin-angular": "~0.12.0",  
    "estraverse": "~4.1.0",  
    "gulp": "~3.9.0",  
    "gulp-angular-filesort": "~1.1.1",  
    "gulp-angular-templatecache": "~1.8.0",  
    "gulp-autoprefixer": "~3.0.2",  
    "gulp-connect-proxy": "^0.3.1",  
    "gulp-env": "^0.4.0",  
    "gulp-eslint": "~1.0.0",  
    "gulp-filter": "~3.0.1",  
    "gulp-flatten": "~0.2.0",  
    "gulp-inject": "~3.0.0",  
    "gulp-jsbeautifier": "^1.0.1",  
    "gulp-load-plugins": "~0.10.0",
    "gulp-minify-css": "~1.2.1",  
    "gulp-minify-html": "~1.0.4",  
    "gulp-ng-annotate": "~1.1.0",  
    "gulp-ng-constant": "^1.1.0",  
    "gulp-protractor": "~1.0.0",  
    "gulp-rename": "~1.2.2",  
    "gulp-replace": "~0.5.4",  
    "gulp-rev": "~6.0.1",  
    "gulp-rev-replace": "~0.4.2",  
    "gulp-sass": "~2.0.4",  
    "gulp-size": "~2.0.0",  
    "gulp-sourcemaps": "~1.6.0",  
    "gulp-uglify": "~1.4.1",  
    "gulp-useref": "~1.3.0",  
    "gulp-util": "~3.0.6",  
    "http-proxy-middleware": "~0.9.0",  
    "karma": "~0.13.10",  
    "karma-angular-filesort": "~1.0.0",  
    "karma-coverage": "~0.5.2",  
    "karma-jasmine": "~0.3.6",  
    "karma-ng-html2js-preprocessor": "~0.2.0",  
    "karma-phantomjs-launcher": "~0.2.1",  
    "lodash": "~3.10.1",  
    "main-bower-files": "~2.9.0",  
    "phantomjs": "~1.9.18",  
    "uglify-save-license": "~0.4.1",  
    "wiredep": "~2.2.2",  
    "wrench": "~1.5.8"  
},  
"engines":  
{  
    "node": ">=0.10.0"  
}  

}

Installed all the dependencies and everything but still I'm getting this error.


Solution

  • Install it locally again. Run npm install --save-dev wrench. Sometimes deleting the node_modules folder and running npm install fixes these kinds of error.