admin管理员组

文章数量:1278853

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._pile (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.

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._pile (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.

Share Improve this question edited Aug 12, 2016 at 13:48 Rajath M S asked Aug 11, 2016 at 14:17 Rajath M SRajath M S 1,0922 gold badges18 silver badges28 bronze badges 2
  • Wrench may not be installed properly. Can you to install manually and try to execute – Optimworks Commented Aug 11, 2016 at 19:08
  • Thank you for the solution, it's working now. I deleted plete directory and installed all dependencies one by one. It's working. – Rajath M S Commented Aug 12, 2016 at 13:52
Add a ment  | 

3 Answers 3

Reset to default 9

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.

I faced the same issue at the beginning, so I ran the above mand

npm install --save-dev wrench

later I got many other missing ponents, finally, I realized that I had an outdated version of npm, so I upgraded the npm to the latest version using this mand

sudo npm i npm@latest -g 

Then everything went well.

no need to do anything in this case just re-run

"npm install"

本文标签: