我在windows 64bit中安装了node.js,当我在本地项目上运行时,我遇到了这个问题。
另一个注意事项:npm install在packages.json
中运行良好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(我正在尝试设置此项目:https://github.com/MarlabsInc/webapi-angularjs-spa)
{
"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"
}
}
这是我的gulp文件:
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']);
答案 0 :(得分:0)
尝试以下操作:
npm uninstall --save-dev gulp-jshint
npm uninstall --save lodash
npm cache clean
npm install --save-dev gulp-jshint
不确定这是您的情况的问题,但有时节点缓存会混乱并出现类似消息。基本上,lodash 应该在安装该软件包时作为 gulp-jshint
的依赖项安装。除非你直接调用 lodash 的一些方法,否则你应该需要手动安装它。
卸载后清理节点缓存,应从头下载并安装包,修复任何依赖错误。
如果这有帮助,请不要忘记投票并标记答案:-)