Error: Cannot find module 'wrench', I'm getting this error, when i run gulp command
Error: Cannot find module 'wrench', I'm getting this error, when i run gulp command
我已经在本地和 globally.Still 中安装了 npm、bower 和 gulp 我在该文件夹中 运行 gulp 时收到此错误。
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)
这是我的 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');
});
这是我的 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"
}
}
已安装所有依赖项和所有内容,但我仍然收到此错误。
重新在本地安装。
运行 npm install --save-dev wrench
。
有时删除 node_modules
文件夹和 运行 npm install
可以修复这些类型的错误。
我一开始遇到了同样的问题,所以我运行上面的命令
npm install --save-dev wrench
后来我得到了很多其他缺失的组件,最后,我意识到我的 npm 版本已经过时,所以我使用这个命令将 npm 升级到最新版本
sudo npm i npm@latest -g
然后一切顺利。
在这种情况下不需要做任何事情 re-run
"npm install"
我已经在本地和 globally.Still 中安装了 npm、bower 和 gulp 我在该文件夹中 运行 gulp 时收到此错误。
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)
这是我的 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');
});
这是我的 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"
}
}
已安装所有依赖项和所有内容,但我仍然收到此错误。
重新在本地安装。
运行 npm install --save-dev wrench
。
有时删除 node_modules
文件夹和 运行 npm install
可以修复这些类型的错误。
我一开始遇到了同样的问题,所以我运行上面的命令
npm install --save-dev wrench
后来我得到了很多其他缺失的组件,最后,我意识到我的 npm 版本已经过时,所以我使用这个命令将 npm 升级到最新版本
sudo npm i npm@latest -g
然后一切顺利。
在这种情况下不需要做任何事情 re-run
"npm install"