我已经在windows 64位中安装了node.js,我在本地项目上运行gulp时遇到了这个。
另一条注解是:使用packages.json安装npm很顺利
Error: Cannot find module 'lodash.assign'
at Function.Module._resolveFilename (module.js:326:15)
at Function.Module._load (module.js:277:25)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (D:\NBCredit_FRTE\RelyToolsSln\RelyTools.Web\node_modules\gulp-jshint\node_modules\lodash.clone\node_modules\lodash._baseclone\index.js:9:14)
at Module._compile (module.js:410:26)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
PS D:\NBCredit_FRTE\RelyToolsSln\RelyTools.Web>
这是我的package.json(我正在尝试设置此项目:(第10页)
{
"name": "webapi-angularjs-spa",
"description": "SPA Demo app with AngularJS",
"author": "Shiju Varghese",
"version": "0.5.0",
"repository": "https://github.com/MarlabsInc/webapi-angularjs-spa",
"devDependencies": {
"gulp-util": "~2.2.14",
"gulp": "~3.9.0",
"gulp-concat": "~2.1.7",
"gulp-uglify": "~0.2.1",
"jshint": "~2.4.3",
"gulp-jshint": "~1.4.2",
"jshint-stylish": "~0.1.5",
"gulp-cssnano": "~2.1.0",
"gulp-rename": "~1.1.0",
"gulp-size": "~0.1.3",
"gulp-rimraf": "~0.2.0",
"gulp-open": "~0.2.8",
"gulp-connect": "~2.0.5"
},
"dependencies": {
"lodash": "^4.2.0"
}
}
这是我吞咽文件:
var gulp = require('gulp'),
gutil = require('gulp-util'),
uglify = require('gulp-uglify'),
jshint = require('gulp-jshint'),
concat = require('gulp-concat'),
jshintreporter = require('jshint-stylish'),
minifycss = require('gulp-minify-css'),
size = require('gulp-size'),
clean = require('gulp-clean'),
rename = require('gulp-rename'),
open = require('gulp-open'),
connect = require('gulp-connect');
var filePath = {
appjsminify: { src: './Scripts/app/**/*.js', dest: './Scripts/app' },
libsjsminify: { src: ['./Scripts/libs/**/*.js', '!*.min.js', '!/**/*.min.js'], dest: './Scripts/libs/' },
jshint: { src: './Scripts/app/**/*.js' },
minifycss: { src: ['./Content/themes/**/*.css', '!*.min.css', '!/**/*.min.css'], dest: './Content/themes/' }
};
gulp.task('app-js-minify', function () {
gulp.src(filePath.appjsminify.src)
.pipe(uglify())
.pipe(concat('ngscripts.js'))
.pipe(size())
.pipe(gulp.dest(filePath.appjsminify.dest));
});
gulp.task('libs-js-minify', function () {
/*Excludes already minified files.*/
gulp.src(filePath.libsjsminify.src)
.pipe(uglify())
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest(filePath.libsjsminify.dest));
});
gulp.task('jshint', function () {
gulp.src(filePath.jshint.src)
.pipe(jshint())
.pipe(jshint.reporter(jshintreporter));
});
gulp.task('minify-css', function () {
/*Excludes already minified files.*/
gulp.src(filePath.minifycss.src)
.pipe(minifycss())
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest(filePath.minifycss.dest));
});
gulp.task('clean', function () {
gulp.src(
[
'Scripts/app/ngscripts.js',
'Scripts/libs/angular-ui/select2.min.js',
'Scripts/libs/select2/select2.min.js',
'Scripts/libs/semantic/semantic.min.js',
'Scripts/libs/**/*.min.js',
'Scripts/libs/jquery-1.9.1.min.js',
'!Scripts/libs/jquery-ui-1.10.3.min.js',
'./Content/themes/semantic/semantic.min.css',
'./Content/themes/Site.min.css',
'./Content/themes/select2/select2.min.css'
], { read: false })
.pipe(clean({ force: true }));
});
gulp.task('build', ['app-js-minify', 'libs-js-minify', 'minify-css']);
gulp.task('cleanbuild', ['clean']);
gulp.task('tests', function () {
connect.server({
port:8000
});
var testUrl = "http://localhost:8000/SpecRunner.html";
gulp.src("./SpecRunner.html")
.pipe(open("", { url: testUrl }));
});
//gulp.watch('./app/**/*.js', ['js']);
1条答案
按热度按时间5anewei61#
请尝试以下操作:
npm uninstall --save-dev gulp-jshint
npm uninstall --save lodash
npm cache clean
npm install --save-dev gulp-jshint
不确定这是您的情况下的问题,但有时节点缓存会混乱,并出现类似的消息。基本上,当安装
gulp-jshint
包时,lodash应该作为gulp-jshint
的依赖项安装。您应该需要手动安装它,除非您直接调用lodash的一些方法。卸载后清除节点缓存时,应从头开始下载并安装程序包,修复所有相关性错误。